Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a production, testing, and development server for a site that I maintain. All three servers are running Apache 2.2.16 on Debian 6 GNU/Linux. I have set up a new version of our company site on the testing server, and my team determined it to be stable enough to move to production. However, I want to make this transition as seamless as possible. I would like to be able to forward requests at production server so they are handled by the testing server. This way, I can test out this new implementation without making any complex configuration changes on the production server.

Ideally, I can use Apache's mod_proxy module to set up a reverse proxy so that I can serve pages directly from the testing server to production clients. I read the documentation at http://httpd.apache.org/docs/2.0/mod/mod_proxy.html, which was very helpful to me. I enabled mod_proxy and mod_proxy_http, then I set the following rules on my development server.

<VirtualHost *:80>
    ServerName dev.example.com
    # ... other <VirtualHost>-specific settings ...

    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    ProxyPass / http://test.example.com/
    ProxyPassReverse / http://test.example.com

    # ... various <Directory> directives ...
</VirtualHost>

This worked very well. When I accessed the development server, the site served all pages directly from the testing server, and it appeared as if these responses came directly from the server I had connected to. Moreover, these requests were rather snappy, and I was able to make both GET and POST requests as if I was talking directly to the testing server.

Unfortunately, this does not fit all of my needs. Since the testing server only runs Apache with a new version of the site, I cannot host webmail or userdirs from the testing server. These requests must be handled by the production server.

I want my production server to be able to use the reverse proxy for all pages except /webmail and the user directories (any directory starting with a tilde). In theory this is possible with <ProxyMatch> directive. However, I do not have sufficient regex-fu to do this. Is there a single rule capable of excluding both of these types of requests from being sent to the proxy server?

Bonus points: I am looking for a good introductory guide to PCRE's, so that I can write my own rules. Does anyone have a recommendation for a regex newbie?

share|improve this question

1 Answer 1

You can't have more than one regular expression in the directive - but you can have a regular expression which implements complex logic:

/http:\/\/test.example.com\/\/(?!webmail)/

I'd recommend the O'Reilly book Mastering regular Expressions but its not an introductory text.

There's lots of online material to get you started. There's a basic tutorial here. But I'd suggest getting a good book on the topic too (but I can't recommend on from personal experience).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.