Forum Moderators: phranque
I have tried many incorrect permutations of rewrite, but for now, I'm having to just have a redirect of [wiki.srv...] => [srv:8080...] and that's all you get... Beside the basic annoyance of Always landing at /Main/, I also have the undesirable side-effect of [wiki.srv...] in URL-history sinking to the end of the list, After all the proper, subsequent :8080 requests which happened at a previous session.
Ideas? Note: these fictitious urls represent my intranet environment.
Setting up such a proxy server with mod_proxy requires some attention, because a small configuration error will turn your computer in an open proxy funerable for all types of malicious actions.
The code would look something like:
# This line is necessary, otherwise it is an open proxy
ProxyRequests Off
# Set some access rules, these will be good I think
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
# Set up the reverse proxy
# See Apache manual for more details on these directives
# All requests for other directories than /ITDocs will
# be handled by the default HTTP server.
ProxyPass /ITDocs h**p://localhost:8080/xwiki/bin/view/ITDocs
ProxyPassReverse /ITDocs h**p://localhost:8080/xwiki/bin/view/ITDocs
Because this is a wiki, it's not possible to write out every possible "directory" (ITDocs in this example). I imagine, however, that I may be able to proxy some "subdirectory" keyword, say, "wiki" as in h**p://srv/wiki/ITDocs, where /wiki would trigger the proxy, and rewrite on *:8080 could determine what to do with h**p://srv:8080/wiki/ITDocs. If so, how might I, now on the *:8080 config, handle "if nothing then Main, else \1"?
hmm.. that is, if I can even fiddle with a *:8080 since geronimo is sitting there controlling everything. I appreciate your help-- this is fun.
# If already on port 8080, skip next two rules
RewriteCond %{SERVER_PORT} ^8080$
RewriteRule ^/ - [S=2]
# Proxy root index requests to /xwiki/bin/view/Main on port 8080
RewriteRule ^/$ http://example.com:8080/xwiki/bin/view/Main/ [P,L]
# Proxy specific page requests to /xwiki/bin/view/<page> on port 8080
RewriteRule ^/(.+)$ http://example.com:8080/xwiki/bin/view/$1 [P,L]
Your sample rewrite directives looks great: if we're on 8080 (which I'll never be at that point: this is in a vhosts.d config file for a given subdomain, for *:80), don't do the cool stuff. Otherwise, proceed and look for a request without a path and/or querystring, pass it to another place (the geronimo server on the same box in my case) on port:8080 via proxy (P). If there is something following (a specific wiki document request), pass it to the same server, port 8080 and include that document requested....
but it won't work for me.. I did notice that I didn't have mod_proxy running, but it is now (without any config..?), and still no va.
This vhosts.d file is for a particular subdomain on port 80, whereas (as in my sample urls above) geronimo is on the main domain, port 8080. Don't know if that will make a difference.