Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set up a reverse proxy on a Mac?

I am currently developing a JavaScript (Sencha) app on my Mac which interfaces with an http REST service.

The service is already in place somewhere else (on another domain) and I have no control over it. Since I am developing the app on my own Mac the http requests are currently cross domain and therefore they don't work unless I disable browser security.

A friend of mine who works on a PC said his solution was to set up a reverse proxy using Apache which somehow made the app (who's domain is localhost) think that the service's domain was also localhost. I'm not entirely sure what he meant by that nor do I know how to do that on my Mac. Any suggestions?

like image 671
Groppe Avatar asked Nov 16 '11 14:11

Groppe


2 Answers

For those seeking a powerful, yet free solution, mitmproxy can act as a reverse proxy. It's a command line tool but with interactive CLI and also offers a web interface. You can directly download it here, it's just a single binary.

To run it as a reverse proxy, just run it with

./mitmproxy --mode "reverse:https://real-destination.example.com"

and then make your client connect to https://localhost:8080. All requests are forwarded to https://real-destination.example.com and TLS is broken up, so you can look into the packets (usually you must install the CA Certificate of mitmproxy on your system and mark it as trusted to make this work).

For those seeking a solution with an interactive UI, a more high level solution that does all system configuration for you, and don't mind spending some money for it, Charles can also act as a reverse proxy and it allows you to configure everything from within the UI application. Charles is also available for iOS on the App Store.

like image 87
Mecki Avatar answered Oct 23 '22 21:10

Mecki


Apache indeed can do reverse proxies, but for your own sake, I'd recommend you don't go with Apache (It's unnecessarily large.)

Though there are many things you can do, what I, personally, would do is install the Nginx webserver and change the configuration to use proxy_pass. It's not terribly hard, but it's especially simple if you are already aware of how to build software from source. A quick google leads to a guide on exactly this - and from there on, you just need to change your ./conf/nginx.conf file to your needs.

Dedicated proxy software is probably a better solution, but you don't need all of the features of a dedicated proxy software, and you certainly don't need all of the features of the Apache web server (or Nginx, really, but Nginx is at least marginally smaller.)

like image 28
John Chadwick Avatar answered Oct 23 '22 20:10

John Chadwick