Last active
August 15, 2018 09:55
-
-
Save petrikoz/8270b8ca7b223db5e42078128c5ebf84 to your computer and use it in GitHub Desktop.
Nginx config for ItCase projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/snippets/letsencrypt.conf | |
location /.well-known { | |
root /var/www/html; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/sites-enabled/default | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server ipv6only=on; | |
server_name _; | |
return 301 https://$host$request_uri; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name www.example.com; | |
ssl_certificate ssl/example/fullchain.pem; | |
ssl_certificate_key ssl/example/key.pem; | |
include enable/ssl.conf; | |
access_log off; | |
return 301 https://example.com$request_uri; | |
} | |
server { | |
listen 443 ssl http2 default_server; | |
listen [::]:443 ssl http2 default_server ipv6only=on; | |
server_name .example.com; | |
ssl_certificate ssl/example/fullchain.pem; | |
ssl_certificate_key ssl/example/key.pem; | |
include enable/acme.conf; | |
include enable/ssl.conf; | |
# Disable images from http:// | |
add_header Content-Security-Policy "block-all-mixed-content"; | |
error_log /home/web/example/log/nginx.error.log; | |
# Yandex Webvisor | |
set $frame_options ''; | |
if ($http_referer !~ '^https?:\/\/([^\/]+\.)?(example\.com|webvisor\.com)\/'){ | |
set $frame_options 'SAMEORIGIN'; | |
} | |
add_header X-Frame-Options $frame_options; | |
set $root /home/web/example; | |
set $src $root/src; | |
root $src; | |
location ~* ^/(static|media) { | |
access_log off; | |
} | |
location ~* ^/(?!sitemap\.xml)[-\w]+\.(txt|xml|html)$ { | |
root $src/media/uploads/seo; | |
access_log off; | |
} | |
location ~ ^/(apple|browserconfig|favicon|mstile)(.*)\.(png|xml|ico)$ { | |
root $src/static/img/favicon; | |
access_log off; | |
} | |
location / { | |
client_max_body_size 10m; | |
include uwsgi_params; | |
uwsgi_pass unix://$root/run/uwsgi_example.sock; | |
uwsgi_read_timeout 300; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/snippets/ssl.conf | |
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'; | |
ssl_prefer_server_ciphers on; | |
ssl_session_timeout 1d; | |
ssl_session_cache shared:SSL:50m; | |
ssl_session_tickets off; | |
ssl_stapling on; | |
ssl_stapling_verify on; | |
resolver 8.8.8.8; | |
add_header Strict-Transport-Security "max-age=31536000"; |
Install certificates to Nginx:
acme.sh --install-cert -d example \
--fullchain-file /etc/nginx/certs/example/fullchain.pem \
--key-file /etc/nginx/certs/example/key.pem \
--reloadcmd "service nginx force-reload"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Enable Forward Secrecy