Last active
November 29, 2023 18:03
-
-
Save jeffhigham-f3/a78171ace822aad7f5a574920ad3fb32 to your computer and use it in GitHub Desktop.
Strapi Nginx Proxy + Certbot
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
server { | |
server_name api.your-strapi-instance.com; | |
listen [::]:443 ssl ipv6only=on; # managed by Certbot | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/api.your-strapi-instance.com/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/api.your-strapi-instance.com/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 | |
location / { | |
proxy_pass http://127.0.0.1:1337; | |
proxy_http_version 1.1; | |
proxy_set_header X-Forwarded-Host $host; | |
proxy_set_header X-Forwarded-Server $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header Host $http_host; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "Upgrade"; | |
proxy_pass_request_headers on; | |
} | |
} |
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
# https://docs.strapi.io/dev-docs/deployment/nginx-proxy | |
apt-get install python | |
apt-get update | |
apt-get install certbot | |
apt-get install python3-certbot-nginx | |
certbot --nginx -d api.your-strapi-instance.com | |
crontab -e | |
0 12 * * * /usr/bin/certbot renew --quiet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment