Редирект на https
1 2 3 4 5 |
server { listen 80; server_name site.ru www.site.ru; return 301 https://$host$request_uri; } |
Подключаем сертификаты, директорию
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
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; root /var/www/site.ru; index index.php index.html index.htm index.nginx-debian.html; location / { if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?q=$1 last; } } location ~ \.php$ { fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; include fastcgi_params; } } |
Редирект с https://www на https://
1 2 3 4 5 6 |
server { listen 443 ssl; server_name www.site.ru; return 301 https://$host$request_uri; } |