Nginx + LetsEncrypt

CONSOLE COMMANDS

nano /etc/apt/sources.list
deb http://ftp.debian.org/debian jessie-backports main

apt-get install certbot -t jessie-backports

24 */12 * * * certbot renew --quiet --post-hook "service nginx reload" >> /dev/null

certbot certonly --webroot -w /var/www/site.com -d site.com -d www.site.com

openssl dhparam -out /etc/letsencrypt/dhparam.pem 2048

NGINX config


server {
listen 80;
listen [::]:80;
server_name www.site.com site.com;
return 301 https://site.com$request_uri;
}

server {
listen 443 ssl;
listen [::]:443 ssl;
server_name www.site.com;
return 301 https://site.com$request_uri;

# SSL START

ssl_certificate /etc/letsencrypt/live/site.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/site.com/privkey.pem;
ssl_dhparam /etc/letsencrypt/dhparam.pem;

ssl_session_cache shared:SSL:5m;
ssl_session_timeout 5m;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS"; # https://wiki.mozilla.org/Security/Server_Side_TLS
ssl_prefer_server_ciphers on;
ssl_stapling on;
ssl_stapling_verify on;
keepalive_timeout 300; # 5 min

add_header Strict-Transport-Security 'max-age=15552000; preload'; # 180 days
}

server {
listen 443 ssl;
listen [::]:443 ssl;
server_name site.com;

# SSL START

ssl_certificate /etc/letsencrypt/live/site.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/site.com/privkey.pem;
ssl_dhparam /etc/letsencrypt/dhparam.pem;

ssl_session_cache shared:SSL:5m;
ssl_session_timeout 5m;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS"; # https://wiki.mozilla.org/Security/Server_Side_TLS
ssl_prefer_server_ciphers on;
ssl_stapling on;
ssl_stapling_verify on;
keepalive_timeout 300; # 5 min

add_header Strict-Transport-Security 'max-age=15552000; preload'; # 180 days

# SSL END

root /var/www/site.com/public;
index index.php index.html;
access_log off; # logs

location ~ /socket.io/ {
proxy_pass http://127.0.0.1:8000$request_uri;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

location ~ /.ht {
deny all;
}

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}

Комментарии: