问题
Currently I use nginx + passenger for serving my rails app. I have been doing some research on reverse proxies and a few names pop up (squid, varnish and nginx mostly).
Now If I am using nginx as my web server can I stil use it as my reverse proxy?
The general sense is that most sites use nginx for proxying static content and apache/mongrel or something like that for dynamic content. If I wanna stick with my nginx, passenger setup, what would my architecture look like when I introduce a reverse proxy? Will it be a separate box or instance of nginx?
What would it look like if I am introducing a load balancer like HAProxy.
Finally, how important are these choices early on? So If I end up regretting a choice (let's say Varnish because it doesn't do well with cookies etc etc), is it easy to switch things around?
Thanks
回答1:
A reverse proxy is a server that sits between your actual app (rails) and the client's browser, and retrieves files on behalf of the client. What is needed to configure a reverse proxy is only to set up a server between the client and the app; since you are already using nginx you can use it as a reverse proxy also.
1 here's a link on SO: nginx be both reverse proxy and web server
2 You can set up a reverse proxy in the same instance or not. If it is a different box or process, you'll need to pass dynamic requests from one box to another.
4 I think it's fairly easy, if you are familiar with both HTTP and configuring those servers. I had a hard time with apache just because I missed a trailing slash
来源:https://stackoverflow.com/questions/3860343/reverse-proxy-confusion