Skip to content

Instantly share code, notes, and snippets.

@ignaciolg
Created June 17, 2014 23:14
Show Gist options
  • Save ignaciolg/12c5a75736954a690547 to your computer and use it in GitHub Desktop.
Save ignaciolg/12c5a75736954a690547 to your computer and use it in GitHub Desktop.
Nginx proxy_pass examples
server {
#listening ip:port
listen 0.0.0.0:80 default_server;
#public data path
root /var/www/nginx/public/;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name subdomain.domain;
#request http://subdomain.domain/path/app/one/more/bar
#will be pass http://127.0.0.1:3000/more/bar
location /path/app/one {
proxy_pass http://127.0.0.1:3000/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#request http://subdomain.domain/path/app/two/more/foo
#will be pass http://127.0.0.1:3001/path/app/two/more/foo
location /path/app/two {
#no normaliced uri forces the pass of all the path
#http://nginx.org/en/docs/http/ngx_http_core_module.html#location
proxy_pass http://127.0.0.1:3001;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment