Skip to content

Instantly share code, notes, and snippets.

@imerr
Last active April 11, 2018 03:18
Show Gist options
  • Save imerr/7fb5ca8a03f7d81838be0f641bc5c956 to your computer and use it in GitHub Desktop.
Save imerr/7fb5ca8a03f7d81838be0f641bc5c956 to your computer and use it in GitHub Desktop.
reverse download nginx proxy
server{
listen 80 default_server;
listen [::]:80 default_server;
allow 1.2.3.4; # whitelist server
deny all;
location / {
return 403;
}
location ~/i/(?<rdomain>[a-zA-Z0-9-\.]+)/ {
rewrite /i/([a-zA-Z0-9-\.]+)/(.*) /$2 break;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $rdomain;
proxy_buffering off;
proxy_pass http://$rdomain;
}
location ~/s/(?<rdomain>[a-zA-Z0-9-\.]+)/ {
rewrite /s/([a-zA-Z0-9-\.]+)/(.*) /$2 break;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $rdomain;
proxy_pass https://$rdomain;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment