最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I set up a reverse proxy on a Mac? - Stack Overflow

programmeradmin2浏览0评论

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?

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?

Share Improve this question edited Mar 20, 2019 at 22:49 Groppe asked Nov 16, 2011 at 14:22 GroppeGroppe 3,87913 gold badges46 silver badges68 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 9

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.

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.)

发布评论

评论列表(0)

  1. 暂无评论