Skip to content

Instantly share code, notes, and snippets.

@agness
Created June 10, 2013 18:16
Show Gist options
  • Save agness/5750977 to your computer and use it in GitHub Desktop.
Save agness/5750977 to your computer and use it in GitHub Desktop.
nginx proxy to any port; i.e. requesting `http://ec2-xx-xx-xx-xx.compute.amazonaws.com/9001/` will forward to `localhost:9001`
server {
listen 80;
server_name localhost;
location ~ /(\d+) {
resolver 8.8.8.8;
rewrite ^/(\d+)/(.*) /$2 break;
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://127.0.0.1:$1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment