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

I am deploying an application and a Wordpress installation on AWS. I have Wordpress set up under Apache on an EC2, and my application under Lighttpd, and I want to reverse-proxy Wordpress through the application node. This works fine, I just set up the reverse proxy in Lighttpd as so:

$HTTP["url"] =~ "^/blog" {
        proxy.server = (
                "/blog" => ( "blog" => ( "host" => "123.456.789.123", "port" => 80 ))
        )
}

url.rewrite-once = (
        "^(.*?)$" => "/index.php/$1"
)

However, the issue is in the rewrite. When I enable rewriting, it catches it before the reverse proxy, and routes to index.php on the application server. I need it to not rewrite if it's going to the blog. I tried various regex matches and other configurations, but I haven't been able to get it to support rewriting and proxying at the same time. How can this be done?

share|improve this question

2 Answers 2

I'd say make your rewrite pattern ignore the paths that are pending for a proxying, but keep the config the same otherwise:

url.rewrite-once = (
    "^((?!/blog).*)$" => "/index.php/$1"
)
share|improve this answer
    
I tried that, but I couldn't get it to work. The answer I just posted worked. –  Jonah Sep 12 '12 at 22:34

I solved it by placing another rewrite entry to match "blog" before the index.php rewrite.

$HTTP["url"] =~ "^/blog" {
        proxy.server = (
                "/blog" => ( "blog" => ( "host" => "123.456.789.012", "port" => 80 ))
        )
}

url.rewrite-once = (
        "^/blog(.*)" => "$0",
        "^(.*?)$" => "/index.php/$1",
)

Since it's using rewrite-once, it will stop at the first match and let it fall through to the proxy server.

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.