Skip to content

Instantly share code, notes, and snippets.

@tobymurray
Last active July 4, 2017 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobymurray/0a81237c9f3df6f786eb2019e5426fbb to your computer and use it in GitHub Desktop.
Save tobymurray/0a81237c9f3df6f786eb2019e5426fbb to your computer and use it in GitHub Desktop.
nginx configuration with proxy to server
server {
listen 80;
listen [::]:80;
server_name example.ca www.example.ca;
location / {
root /home/toby/client;
index index.html
try_files $uri $uri/ /index.html;
}
location /api/ {
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_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:3000/;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.ca/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.ca/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
if ($scheme != "https") {
return 301 https://$host$request_uri;
} # managed by Certbot
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment