Created
September 11, 2023 01:52
-
-
Save asrofilfachrulr/98ed44fbac0c74a6b8f1098dfa9d9daa to your computer and use it in GitHub Desktop.
Nginx Simple Config for Fullstack App (with https)
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
upstream api { | |
server localhost:8080; | |
} | |
upstream frontend { | |
server localhost:3000; | |
} | |
server { | |
listen 80; | |
server_name <your-domain-name>; | |
return 301 https://$server_name$request_uri; | |
} | |
server { | |
listen 443 ssl; | |
server_name <your-domain-name>; | |
error_log /var/log/nginx/error.log; | |
access_log /var/log/nginx/access.log; | |
include snippets/well-known.conf; | |
ssl_certificate /etc/letsencrypt/live/<your-domain-name>/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/<your-domain-name>/privkey.pem; | |
ssl_trusted_certificate /etc/letsencrypt/live/<your-domain-name>/chain.pem; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; | |
location / { | |
proxy_pass http://frontend; | |
} | |
location /api { | |
rewrite ^/api/(.*)$ /$1 break; | |
proxy_pass http://api; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment