Как грамотно сделать редирект https nginx?
Доброго времени суток.
Пробовал ставить редирект на https, но он у меня циклится
rewrite ^(.*) https://$server_name$1 permanent;
как будет сделать это правильно, подскажите пожалуйста
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; } }
Пробовал ставить редирект на https, но он у меня циклится
rewrite ^(.*) https://$server_name$1 permanent;
как будет сделать это правильно, подскажите пожалуйста
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; } }