Last active
December 14, 2022 20:49
-
-
Save donpdonp/9b663f1806b90b8ede73810af2d06e06 to your computer and use it in GitHub Desktop.
nginx.conf https only with letsencrypt using lego client
This file contains hidden or 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/example.com.conf | |
server { | |
listen 80; | |
server_name .example.com; | |
root /var/letsencrypt/webcache; | |
location /.well-known { | |
try_files $uri =404; | |
} | |
location / { | |
return 301 https://$host$request_uri; | |
} | |
} | |
server { | |
listen 443 ssl; | |
server_name .example.com; | |
ssl_certificate /var/letsencrypt/certificates/example.com.crt; | |
ssl_certificate_key /var/letsencrypt/certificates/example.com.key; | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_pass http://internal-content-host; | |
} | |
} |
This file contains hidden or 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
# one time setup | |
$ go get -u github.com/xenolf/lego | |
$ lego --email [email protected] --domains example.com --path /var/letsencrypt --webroot /var/letsencrypt/webcache run | |
# renew (can be run from cron) | |
$ lego --email [email protected] --domains example.com --path /var/letsencrypt --webroot /var/letsencrypt/webcache renew |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment