Reverse Proxy

I would like to reverse proxy a few sites for geo location reasons (I don’t own the final domain). I thought it would be as easy as setting up proxy pass on a domain I own with the location pointing to the target domain and while this works for the homepage, as soon as I click a link it starts being served from the target domain.

I’m sure I’m doing something obviously wrong!

I was going to setup a VPN and route traffic depending on rules but my unifi usg doesn’t seem to support “URL” based routing. I could setup *sense and remove my usg, but that would make me a little bit sad.

Thoughts please

single core

multi core


You need to replace all links on the page and catch redirects.
Nginx can do it either via sub_filter or with Lua (if it’s compiled with it). I use something similar to this:

        location / {
                set $site "";

                resolver valid=3600s;
                resolver_timeout 15s;

                proxy_set_header Accept-Encoding "";
                proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
                proxy_ssl_session_reuse on;

                proxy_set_header Connection "Keep-Alive";
                proxy_set_header Proxy-Connection "Keep-Alive";
                proxy_set_header Host $site;
                proxy_redirect https://$site/ https://$host/;

                body_filter_by_lua '
                        ngx.arg[1] =[1], "//", "//")
                        ngx.arg[1] =[1], "//", "//")
                        ngx.arg[1] =[1], "//", "//")

                proxy_pass https://$site;

If you don’t have Lua, just do something like sub_filter '//' '//';


That’s interesting

Try this : MITM Proxy