Created
January 3, 2018 11:48
-
-
Save lengerfulluse/d15d50ff1bd7fe973ff48ada12935b05 to your computer and use it in GitHub Desktop.
configure ssl redirect for nginx
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
# http part | |
server { | |
listen 80; | |
listen [::]:80; | |
root /var/www/hengwei.me/html; | |
index index.html index.htm; | |
# Make site accessible from http://localhost/ | |
server_name hengwei.me www.hengwei.me; | |
return 301 https://$server_name$request_uri; | |
location / { | |
# First attempt to serve request as file, then | |
# as directory, then fall back to displaying a 404. | |
try_files $uri $uri/ =404; | |
# Uncomment to enable naxsi on this location | |
# include /etc/nginx/naxsi.rules | |
} | |
} | |
# ssl part | |
server { | |
root /var/www/hengwei.me/html; | |
index index.html index.htm; | |
server_name hengwei.me; | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/hengwei.me/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/hengwei.me/privkey.pem; # managed by Certbot | |
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot | |
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment