1

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?

Jonah
  • 169
  • 2
  • 9

2 Answers2

0

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"
)
Shane Madden
  • 114,520
  • 13
  • 181
  • 251
0

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.

Jonah
  • 169
  • 2
  • 9