Answer the question
In order to leave comments, you need to log in
How to make a redirect from all domains to the main one?
There is the main domain site1.ru, as well as several others (site2.ru, site3.ru ...). It is necessary to redirect all additional domains to the main one with the code 301. Please tell me how to do this correctly?
Now these settings are:
s1.conf
# Ansible managed
# Additional website http
server {
listen 80 default_server;
server_name _;
access_log /var/log/nginx/default_access.log main;
error_log /var/log/nginx/default_error.log warn;
#charset utf-8;
server_name_in_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:80;
set $proxyserver "http://127.0.0.1:8888";
set $docroot "/var/www/html";
index index.php;
root "/var/www/html";
proxy_ignore_client_abort off;
#Redirect to ssl if need
#if (-f /var/www/html/.htsecure) { rewrite ^(.*)$ https://$host$1 permanent; }
if (-f /var/www/html/.htsecure) { rewrite ^(.*)$ https://site1.ru$1 permanent; }
# Include parameters common to all websites
include bx/conf/bitrix.conf;
# Include munin and nagios web
include bx/server_monitor.conf;
}
# Ansible managed
# Additional website http
server {
listen 443 default_server ssl http2;
server_name _;
include bx/conf/ssl.conf;
access_log /var/log/nginx/default_access.log main;
error_log /var/log/nginx/default_error.log warn;
#charset utf-8;
server_name_in_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:443;
proxy_set_header HTTPS YES;
proxy_set_header X-Forwarded-Proto https;
set $proxyserver "http://127.0.0.1:8888";
set $docroot "/home/bitrix/ext_www/default";
index index.php;
root "/home/bitrix/ext_www/default";
proxy_ignore_client_abort off;
# Include parameters common to all websites
include bx/conf/bitrix.conf;
# Include munin and nagios web
include bx/server_monitor.conf;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question