Apache Rewrite or Proxy

I have an Apache server running on my machine (port 80) I have a Zope server running on my machine (port 8080).

I want all users, no matter where the domain is located (now you can use www.example.com), will be placed in the zope instance without problems

IE if I enter my browser http://www.example.com/mysite

it will show the effects of http://www.example.com:8080/mysite

BUT

I want the url to still say http://www.example.com/mysite

(sub-) domain must be independent, as it will have 2 or 3 domains pointing to the same server

Should I look at mod_rewrite or mod_proxy?

Mod_rewrite works for me, but it changes what is in the browser?

currently trying

RewriteEngine on RewriteRule ^($|/.*) http://localhost:8080/$1 [P] 

but getting server 500

Connection using "http: // localhost / mysite"

+4
source share
2 answers

Zope supports your out-of-box scenario with some special rewriting using the VirtualHostMonster flags on the go. This ensures that any URLs created by Zope (and by extension, Plone) are also valid for proxied requests.

You must use both mod_rewrite and mod_proxy , they will work together.

To make it easier to create the correct rewrite URLs, someone created a great RewriteRule Witch . Inclusion of your specific example:

 RewriteRule ^/mysite($|/.*) \ http://127.0.0.1:8080/VirtualHostBase/\ http/%{SERVER_NAME}:80/mysite/VirtualHostRoot/_vh_mysite$1 [L,P] 

Thus, for any URLs embedded at http://www.example.com/mysite , rewrite them for service from a server running on port 8080 localhost, making sure that Zope generates URLs with the same root .

For more information, see the detailed documentation for the VirtualHostMonster feature on the Zope wiki.

+3
source

You can use either mod_rewrite with the P rule (proxy) or mod_proxy to do what you want. Using mod_rewrite , your configuration will look something like this:

 RewriteRule ^/mysite/(.*) http://www.example.com:8080/mysite/$1 [P] 

Using mod_proxy , your configuration will look like this:

 <Location /mysite/> ProxyPass http://www.example.com:8080/ ProxyPassReverse http://www.example.com:8080/ </Location> 

Both do roughly the same thing. Using the Location block with ProxyPass makes it easy to apply other configuration directives to this path on the external server.

+3
source

All Articles