Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

proxy directives

Status
Not open for further replies.

deesto

Instructor
Feb 24, 2005
11
US
I could really use a hand with what I think is an apache proxy problem.

Let's say I have a directory on Server A called /var/ I would like all web requests to be proxied by another server, Server B.

I would like any requests that call for to be served by /var/ on Server A, but I would like the URL to maintain the path shown by Server B (for example: /var/ on Server A could be viewed at ).

What would be the best apache directive and approach to accomplish this?

Also, if you can recommend a good book that might help demystify all this, I'd really appreciate it. The apache online docs are clear and very thorough, especially when you know exactly what you're looking for, but I'm finding myself going in circles on this one.

More info (only if it helps):
This may be too much information for this problem, but I am currently serving two directories on one machine, one authenticated (HTTPS) and one not (HTTP). Further, the authenticated directory contains dynamic content generated by scripts, and the unauthetnicated pages are crawled, HTML-only versions of the dynamic content. Finally, although the actual content between the two is essentially the same, the sub-directory structure isn't, due to the results of the crawler versus the much more flat nature of the scripted content.

So, what I want to do is:
- Proxy both the HTTP and HTTPS content from another server, so that the server host name will not appear to be different, save for the "S" in "HTTPS" (I've already got this working, albeit probably not the right way).
- Create a "virtual" directory structure that mirrors one server instance for the other, even though that directory does not actually exist in the other (/dir/ect/ory/ versus /directory). In essence, I need the URL space for the server instances to match (except for "HTTP:" versus "HTTPS:").

Eventually, I will move the HTTP stuff to a separate server so the HTTPS stuff will be a bit more secure, which may alleviate some (but not all) of these issues.

Thank you,
~John
 
On the proxy server ("proxy"), I've added the following:
Code:
ReWriteEngine On
RewriteRule  ^/dir/ect/ory/$ [URL unfurl="true"]http://server/directory/[/URL] [R]

This works in general, but the browser displays proxy/directory/ instead of proxy/dir/ect/ory/, which is what I would like it to show (is that a transparent proxy?).

I've also had to write additional rules for subdirectories, which tells me I'm probably doing something wrong:
Code:
RewriteRule  ^/dir/ect/ory/subdir$ [URL unfurl="true"]http://server/directory/subdir[/URL] [R]

Any thoughts on how to fix this? These are pure stabs in the dark.

Thanks.
 
I think a very simple pair of ProxyPass|ProxyPassReverse directives could replace some of this stuff, but not all... what about this on the proxy server:
Code:
ProxyPass /dir/ect/ory [URL unfurl="true"]http://server/directory[/URL]
ProxyPassReverse /dir/ect/ory [URL unfurl="true"]http://server/directory[/URL]

That seems to do exactly what I need as far as the client-side URL goes.

The problem is the subdirs: I'm doing this because I need to mirror TWiki pages (which are not .HTML files) with their HTML counterparts. The TWiki treats URL space a bit differently (their "webs" and "topics" appear as directories without a trailing slash in the URL). So when you browse to a specific page of the TWiki, you don't append .html to the URL because it doesn't exist. However, it's there on the HTML mirror, and I need something to not ony append the .html suffix to each incoming request, but to be able to tell whether the request is looking for a file or a directory.

The RewriteRule above works for that, if I duplicate it so it appears with and without the trailing slash, and for each subdirectory (I'm sure there's a better way... I can't figure out the syntax to condense it all). But that doesn't help with the URL space issue that ProxyPass seems to help with.
 
Folks, any ideas on how to get this working, or to improve the methods I've tried? I'd really appreciate your help.
 
OK... can anyone help me figure out how to clean this up on the proxy's httpd.conf?
Code:
<VirtualHost *:80>
    ServerAdmin webmaster@webserver
    ServerName webserver
    ReWriteEngine On
    RewriteLogLevel 2
    RewriteRule  ^/dir/ect/ory/misc/(\w+)(/.*)$  /directory/$1/misc/$1$2 [P,L]
    RewriteRule  ^/dir/ect/ory/(\w+)/misc(/.*)$  /directory/$1/misc$2 [P,L]
    RewriteRule  ^/dir/ect/misc/(\w+)(/.*)$  /directory/$1/misc/$1$2 [P,L]
    RewriteRule  ^/dir/ect/(\w+)/misc(/.*)$  /directory/$1/misc$2 [P,L]
    RewriteRule  ^/dir/misc/(\w+)(/.*)$  /directory/$1/misc/$1$2 [P,L]
    RewriteRule  ^/dir/(\w+)/misc(/.*)$  /directory/$1/misc$2 [P,L]
    RewriteRule  ^/dir/ect/ory/(\w+)/(\w+).html$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir/ect/ory/(\w+).html$  /directory/Main/$1.html [P,L]
    RewriteRule  ^/dir/ect/ory/(\w+)/(\w+)$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir/ect/ory/(\w+)/?$  /directory/$1/WebHome.html [P,L]
    RewriteRule  ^/dir/ect/ory/?$  /directory/Main/WebHome.html [P,L]
    RewriteRule  ^/dir/ect/(\w+)/(\w+).html$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir/ect/(\w+).html$  /directory/Main/$1.html [P,L]
    RewriteRule  ^/dir/ect/(\w+)/(\w+)$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir/ect/(\w+)/?$  /directory/$1/WebHome.html [P,L]
    RewriteRule  ^/dir/ect/?$  /directory/Main/WebHome.html [P,L]
    RewriteRule  ^/dir/(\w+)/(\w+).html$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir/(\w+).html$  /directory/Main/$1.html [P,L]
    RewriteRule  ^/dir/(\w+)/(\w+)$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir/(\w+)/?$  /directory/$1/WebHome.html [P,L]
    RewriteRule  ^/dir/?$  /directory/Main/WebHome.html [P,L]
    ProxyPass /directory [URL unfurl="true"]http://webserver/directory[/URL]
    ProxyPassReverse /directory  [URL unfurl="true"]http://webserver/directory[/URL]
</VirtualHost>

It finds all the files and directories, but some of the redirects give screwy URLs, and there's probably a much more efficient way to do all this.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top