Answer the question
In order to leave comments, you need to log in
How to properly redirect https nginx?
Good day.
I tried to redirect to https, but it cycles for me rewrite ^(.*) https://$server_name$1 permanent;
how to do it right, tell me please
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_certificate /etc/ssl/example.ru.crt;
ssl_certificate_key /etc/ssl/example.ru.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
server_name www.example.ru example.ru maestra.deathstar.name;
root /home/maestra/www/example.ru;
access_log /var/log/nginx/example.ru_access.log;
error_log /var/log/nginx/example.ru_error.log;
index index.php;
charset UTF-8;
include /etc/nginx/default.d/*.conf;
location / {
try_files $uri @rewrite;
}
location @rewrite {
rewrite ^/(.+)$ /index.php?path=$1 last;
}
location ~* ^.+\.(ogg|webp|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|css|js)$ {
access_log off;
log_not_found off;
# expires 7d;
add_header Cache-Control public,max-age=604800;
}
location ~ \.php$ {
limit_req zone=dynamic burst=5;
fastcgi_pass maestra;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
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