I'm looking for a way to implement a proxy strategy for local web development integrating to other apps and services. The app I'm trying to develop integrates with several other apps on the same site (e.g.
Here are some of the challenges:
It is very difficult to stand up the other apps in a local context because of their dependencies/proprietary systems. It is easier to point integrations at actual deployed environments (e.g. stage).
Outbound integrations can be configured, but inbound integrations break. For example, if a user is not logged in
local/myapp, then we redirect to
stage/login(another app in the target integration) which logs a user in and redirects back to
stage/myapp, but on the wrong domain. Furthermore, the login cookie is written to the wrong domain context (stage, not local).
Designing stage/login so that it can return to arbitrary locations using a return param, like url=local/myapp is a security risk.
SSL is provided by another layer, meaning that local development is not configured for SSL, but local to stage integration would require switching contexts:
http://local/myapp -> https://stage/login -> http://local/myapp.
My local development copy runs on
What I would like is the ability to setup a proxy such that traffic going to:
- everything else goes to the originally requested url
The effect I would like to achieve is like Charles Proxy's map remote feature, allowing a locally served site to 'overlay' a remote site.
I've read about various Apache modules mod_proxy, mod_rewrite and basically want a forwarding proxy for everything except a chosen subdirectory (maybe rewrite? maybe reverse proxy?). I've also looked at Squid.
I've tried several combinations, but I'm lacking the general approach for doing this. Is something like this possible using Apache mod_proxy and/or mod_rewrite?
For some context, here's my attempt so far, but I can only get the forward proxy to work. I'm using Firefox and setting the proxy for all protocols to
Listen 8118 <VirtualHost *:8118> # Enable forward proxy ProxyRequests On # Add "Via" header ProxyVia On <Proxy *> Order deny,allow Deny from all Allow from example.com # local devs only! </Proxy> # local Rails app, e.g. $ rails s -e stage # local request: http://myworkstation.dhcp.example.com:3000/myapp # normal stage requests: https://stage.example.com/myapp # app logs in via another app: https://stage.example.com/login # which I want to delegate to without standing up another local app. # which to use? hmmm... #ProxyRemote "https://stage.example.com/myapp/" "http://myworkstation.dhcp.example.com:3000/myapp/" #ProxyPass /myapp http://myworkstation.dhcp.example.com:3000/myapp #ProxyPassReverse /myapp/ http://myworkstation.dhcp.example.com:3000/myapp/ #RewriteEngine on #RewriteBase "/myapp/" #RewriteRule "^/myapp/(.*)$" "http://myworkstation.dhcp.example.com:3000/myapp/$1" [P] #ProxyPassReverse "/myapp/" "http://myworkstation.dhcp.example.com:3000/myapp/" # another approach, maybe via Passenger? ServerName integration-proxy ErrorLog "/var/log/apache2/integration-proxy-error.log" </VirtualHost>