Last active
March 20, 2019 04:59
-
-
Save nmfzone/2f7df5ee32dabc8c24822bebf1c0c133 to your computer and use it in GitHub Desktop.
Nginx Config for JS Family (Nuxt, Angular, Next, Express)
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
location ^~ /.well-known/acme-challenge/ { | |
default_type "text/plain"; | |
root /var/www/letsencrypt; | |
} |
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
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-NginX-Proxy true; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header Host $http_host; | |
proxy_cache_bypass $http_upgrade; | |
proxy_redirect off; |
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 80; | |
listen [::]:80; | |
server_name domain.com; | |
include /etc/nginx/snippets/letsencrypt.conf; | |
# Redirect http://domain.com to https://domain.com | |
location / { | |
return 301 https://domain.com$request_uri; | |
} | |
} | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name www.domain.com; | |
include /etc/nginx/snippets/letsencrypt.conf; | |
# Redirect http://www.domain.com to https://www.domain.com | |
location / { | |
return 301 https://www.domain.com$request_uri; | |
} | |
} | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name domain.com; | |
ssl on; | |
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; | |
ssl_trusted_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; | |
include /etc/nginx/snippets/ssl.conf; | |
# Redirect https://domain.com to https://www.domain.com | |
location / { | |
return 301 https://www.domain.com$request_uri; | |
} | |
} | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name www.domain.com; | |
ssl on; | |
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; | |
ssl_trusted_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; | |
include /etc/nginx/snippets/ssl.conf; | |
location / { | |
proxy_pass http://localhost:5001; | |
include /etc/nginx/snippets/proxy.conf; | |
} | |
location /socket.io { | |
proxy_pass http://localhost:5002; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "Upgrade"; | |
} | |
} |
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
ssl_session_timeout 1d; | |
ssl_session_cache shared:SSL:50m; | |
ssl_session_tickets off; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
ssl_prefer_server_ciphers on; | |
ssl_dhparam /etc/ssl/certs/dhparam.pem; | |
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'; | |
# OCSP Stapling --- | |
# fetch OCSP records from URL in ssl_certificate and cache them | |
ssl_stapling on; | |
ssl_stapling_verify on; | |
add_header Strict-Transport-Security "max-age=15768000; includeSubdomains; preload"; | |
add_header X-Frame-Options DENY; | |
add_header X-Content-Type-Options nosniff; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment