Forum Moderators: phranque

Message Too Old, No Replies

reverse proxy with rewriterule

         

JHuuskonen

1:08 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



Hi, i have wondered quite long time howto do following reverse proxy with rewriterule.
I am trying as follows, to get from server.domain.com server2.domain.com/forums/ content to server.domain.com/forums/ url.

RedirectMatch 301 ^/$ /forums/
ProxyPass /forums/ http://server2.domain.com/forums/
ProxyPassReverse /forums/ \ http://server2.domain.com/forums/

and rewriterule what i am using is.

RewriteCond %{HTTP_HOST} ^server\.domain\.com
RewriteRule ^(.*)$ http://server2.domain.com/forums/$1 [P]
ProxyPassReverse /forums/ http://server2.domain.com/forums/

this is working with one execption server2 content is seen in server.domain.com url with no /forums/ howto do rule which redirects asked ^(.*)$ so that server.domain.com/forums/ is shown in requested url.

[edited by: jdMorgan at 2:31 pm (utc) on April 5, 2006]
[edit reason] De-linked [/edit]

jdMorgan

2:30 pm on Apr 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



JHuuskonen,

Welcome to WebmasterWorld!

Three points which may bear on the problem:

1) Directives are not executed strictly in the order that you specify. They are executed in module order. For example, all mod_alias directives will execute, then all mod_proxy diretives will execute, and then all mod_rewrite directives will execute (Each module parses the config files and executes the directives that it recognizes).

That's just an example -- the modules will execute in the reverse order the they are loaded (by LoadModule) on Apache 1.x, and in the order determined by Apache 2.x priority scheme. This can have various unexpected results.

2) Why is the backslash character in this line?

ProxyPassReverse /forums/ [b]\[/b] http://server2.domain.com/forums/

3) According to the mod_proxy documentation [httpd.apache.org],

Note that this ProxyPassReverse directive can also be used in conjunction with the proxy pass-through feature ("RewriteRule ... [P]") from mod_rewrite because its doesn't depend on a corresponding ProxyPass directive.

So you may not need the ProxyPass function at all.

Jim

JHuuskonen

6:25 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



1. I had no clue that module order is important. Certainly nice to know :)

2. Typo sorry for that.

3. That also true, when using [P] with rule there is no need to use proxypassreverse directive.

Thanks for information.