Skip to content

Instantly share code, notes, and snippets.

@faberyx
Last active April 11, 2017 09:53
Show Gist options
  • Save faberyx/f35eeda11c86783973de2d368e95500a to your computer and use it in GitHub Desktop.
Save faberyx/f35eeda11c86783973de2d368e95500a to your computer and use it in GitHub Desktop.
nginx proxy
# loca
upstream app_indico {
server 127.0.0.1:3001;
}
upstream app_thezoo{
server 127.0.0.1:3002;
}
upstream app_thezoo_server{
server 127.0.0.1:3003;
}
#Point http requests to https
server {
listen 0.0.0.0:80;
server_name indicodevserver.tk;
server_tokens off;
return 301 https://$host$request_uri;
}
# default instance and node
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/indicodevserver.tk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/indicodevserver.tk/privkey.pem;
server_name indicodevserver.tk;
access_log /var/log/nginx/indico.log;
error_log /var/log/nginx/indico_error.log;
# pass the request to the node.js server with the correct headers and much more can be added, see nginx config options
location / {
# auth_basic "Restricted";
# auth_basic_user_file /home/ubuntu/app/.htpasswd;
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_set_header X-Ssl on;
proxy_pass http://app_indico;
proxy_redirect off;
}
}
# thezoo instance
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/thezoodevserver.tk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/thezoodevserver.tk/privkey.pem;
server_name thezoodevserver.tk;
access_log /var/log/nginx/thezoo.log;
error_log /var/log/nginx/thezoo_error.log;
# pass the request to the node.js server with the correct headers and much more can be added, see nginx config options
location / {
# auth_basic "Restricted";
# auth_basic_user_file /home/ubuntu/app/.htpasswd;
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_set_header X-Ssl on;
proxy_pass http://app_thezoo;
proxy_redirect off;
}
location /server/ {
rewrite /server/(.*)$ /$1 break;
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_set_header X-Ssl on;
proxy_pass http://app_thezoo_server;
proxy_redirect off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment