Skip to content

Instantly share code, notes, and snippets.

@asrofilfachrulr
Created September 11, 2023 01:52
Show Gist options
  • Save asrofilfachrulr/98ed44fbac0c74a6b8f1098dfa9d9daa to your computer and use it in GitHub Desktop.
Save asrofilfachrulr/98ed44fbac0c74a6b8f1098dfa9d9daa to your computer and use it in GitHub Desktop.
Nginx Simple Config for Fullstack App (with https)
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