basics of a reverse proxy? what am I missing?

試著忘記壹切 提交于 2019-12-24 07:07:10

问题


I am no server admin, just a web developer trying to act as such. :)

We have website A and website B. Website A has a subdomain called subby.websitea.com, which connects via A name to ANOTHER server. I was told that in order to make subby.websitea.com APPEAR as a subFOLDER of website A (ie. websitea.com/subby/) than a reverse proxy is needed.

well, I've been looking at documentation all night and I just.... I don't get the basics! My host was kind enough to set up our VPS with the info outlined here: http://www.apachetutor.org/admin/reverseproxies

But... then what!? How do I make this work? Do I now edit the htaccess file? I haven't found a good simple explanation of how it works. I love learning, but I think I have to get over this basic hump first.... :)


回答1:


Since it's part (or all of it?) of your question, a reverse proxy is basically a gateway, or intermediary between a server and its clients. Requests are sent to the reverse proxy, and it (the reverse-proxy) forwards them to the server.
There are lots of other features on a reverse, like load-balancing and caching. I guess a Google search should point you to more resources and documentations on the matter.

As I understand it, you have two websites (subby.websitea.com / www.websitea.com) and you want 'www.websitea.com/subby' to forward to "subby.websitea.com".

EDITED PART: You have access to Apache config, so you need to enable mod_proxy and mod_proxy_http in httpd.conf. Then uncomment

Include extra/httpd-vhost.conf

(in http.conf, at the end of the file).

You must then edit the httpd-vhost.conf file to add your proxy directives.

<VirtualHost *:80>
/* Other default config like Documentroot, etc */
ProxyRequests Off
ProxyPass /subby/ http://subby.websitea.com/
ProxyPassReverse /subby/ http://subby.websitea.com/
</VirtualHost>

Now, everything that comes in http://www.websitea.com/subby/ would be forwarded to http://subby.websitea.com without the adress getting altered.

EDIT AGAIN: I forgot to say: remember to restart Apache each time you change something in the .conf files.

Hope this helps.




回答2:


Enable mod_proxy and mod_proxy_http

# a2enmod proxy_http this should also enable mod_proxy as a dependency.

Create a new VirtualHosts file /etc/apache2/sites-available/subby.websitea.com with the content:

<virtualhost *>
  ServerName subby.websitea.com
  ProxyRequests off
  ProxyPass / http://192.168.1.15/
  ProxyPassReverse / http://192.168.1.15/
</virtualhost>

Enable the new site:

a2ensite subby.websitea.com

Reload Apache:

service apace2 reload

Done.



来源:https://stackoverflow.com/questions/9270956/basics-of-a-reverse-proxy-what-am-i-missing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!