Answer the question
In order to leave comments, you need to log in
Why does nginx not redirect from https://www.site.ru?
I noticed that the search engine shaval https://www.site.ru and ofigel is simple), it should be https://site.ru
Config:
server {
listen 80;
server_name site.ru www.site.ru;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen 443 ssl;
server_name www.site.ru site.ru;
ssl_certificate /etc/letsencrypt/live/site.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/site.ru/privkey.pem;
access_log /var/www/site.ru/logs/nginx-access.log;
error_log /var/www/site.ru/logs/nginx-error.log;
location / {
proxy_pass http://127.0.0.1:81;
include /etc/nginx/proxy.conf;
}
location ~* \.(jpg|jpeg|gif|png|ico|css|bmp|swf|js)$ {
root /var/www/site.ru/public;
access_log off;
expires 10d;
}
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
proxy_pass http://127.0.0.1:81;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
}
Answer the question
In order to leave comments, you need to log in
because you have written rewrite like that
server_name site.ru www.site.ru;
rewrite ^(.*) https://$server_name$1 permanent;
server {
listen 80;
server_name site.ru www.site.ru;
return 301 https://site.ru$request_uri;
}
server {
listen 443 ssl;
server_name www.site.ru;
ssl_certificate /etc/letsencrypt/live/site.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/site.ru/privkey.pem;
return 301 https://site.ru$request_uri;
}
server {
listen 443 ssl;
server_name site.ru;
ssl_certificate /etc/letsencrypt/live/site.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/site.ru/privkey.pem;
access_log /var/www/site.ru/logs/nginx-access.log;
error_log /var/www/site.ru/logs/nginx-error.log;
location / {
proxy_pass http://127.0.0.1:81;
include /etc/nginx/proxy.conf;
}
location ~* \.(jpg|jpeg|gif|png|ico|css|bmp|swf|js)$ {
root /var/www/site.ru/public;
access_log off;
expires 10d;
}
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
proxy_pass http://127.0.0.1:81;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question