Answer the question
In order to leave comments, you need to log in
Setting up Nginx after changing domain?
There is such a config:
server {
server_name site.com www.site.com;
charset off;
index index.php index.html;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/site.com/*.conf;
access_log /var/www/httpd-logs/site.com.access.log;
error_log /var/www/httpd-logs/site.com.error.log notice;
ssi on;
set $root_path /var/www/name/data/www/site.com;
root $root_path;
location / {
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @fallback;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
try_files $uri $ uri/@fallback;
}
location / {
try_files /does_not_exists @fallback;
}
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_redirect 127.0.0.1:8080 /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
access_logoff;
}
listen 11.111.11.11:80;
}
server {
server_name site.com www.site.com;
ssl_certificate "/var/www/httpd-cert/name/name.crt";
ssl_certificate_key "/var/www/httpd-cert/name/name.key";
ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
add_header Strict-Transport-Security "max-age=31536000;";
ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
charset off;
index index.php index.html;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/site.com/*.conf;
access_log /var/www/httpd-logs/site.com.access.log;
error_log /var/www/httpd-logs/site.com.error.log notice;
ssi on;
set $root_path /var/www/golden/data/www/site.com;
root $root_path;
location / {
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @fallback;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
try_files $uri $uri/ @fallback;
}
location / {
try_files /does_not_exists @fallback;
}
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_redirect 127.0.0.1:8080 /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
access_logoff;
}
listen 11.111.11.11:443 ssl;
}
I changed the domain from site.COM to site.RU. Set a redirect:
rewrite ^/(.*)$ https://site.ru/$1 permanent;
It redirects from site.com to site.ru, but site.ru also redirects to itself. It turns out a cyclic redirect. Help fix this.
Answer the question
In order to leave comments, you need to log in
If you changed everything correctly everywhere in the config, then a redirect is not needed.
It turns out that you are for:
server {
server_name site.ru www.site.ru;
***
}
server {
server_name site.ru www.site.ru;
rewrite ^/(.*)$ https://site.ru/$1 permanent;
***
}
server {
server_name site.com www.site.com;
rewrite ^/(.*)$ https://site.ru/$1 permanent;
***
}
server {
server_name site.ru www.site.ru;
***
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question