2

We run a site based on Zend Framework using apache httpd (2.2) with mod_rewrite for SEO and usability friendly URL:s. Recently we added mod_proxy (and mod_proxy_balancer, mod_proxy_http, mod_rpaf) for setting up a loadbalancer virtual-host.

Our setup now looks like:

external.site.com (vhost on server1.site.com with reverse proxy)
|-internal1.site.com (vhost on server1.site.com) 
|-internal2.site.com (vhost on server2.site.com)

Where internal1 & internal2 serves most of the dynamic content and external serves static content plus some admin type pages. All the vhosts have got the same code and .htaccess setup.

The problem is that on external.site.com the RewriteRule doesn't add the correct headers to the request environment, specifically REDIRECT_URL which we and ZendFramework depend upon. Everything works fine for the requests that are forwarded to the internal vhosts.

The relevant parts of the httpd.conf:

<VirtualHost *:80>
  ServerName external.site.com
  DocumentRoot /opt/www/htdocs/
  CustomLog "/var/log/httpd-proxy-access.log" combined

  <Proxy balancer://backend/>
    Balancermember http://internal1.site.com
    Balancermember http://internal2.site.com
    ProxySet lbmethod=byrequests
  </Proxy>
  ProxyRequests Off
  <Proxy *>
    Order deny,allow
    Allow from all
  </Proxy>
  ProxyPass /static/ !
  ProxyPass /config/ !
  ProxyPass / balancer://backend/
  ProxyPassReverse / balancer://backend/
</VirtualHost>
<VirtualHost *:80>
  ServerName internal1.site.com

  RPAFenable On
  RPAFproxy_ips 127.0.0.1
</VirtualHost>

From the .htaccess file:

RewriteEngine on 
RewriteCond %{REQUEST_URI} !^.*robots.txt
RewriteCond %{REQUEST_URI} !^.*/static/.*
  RewriteRule .* index.php [L]

php_flag magic_quotes_gpc off 
php_flag register_globals off

Because there only is a problem on the external vhost we assume it is a problem with the mod_proxy and mod_rewrite combination. Any ideas?

Regards

2

4 Answers 4

0

I am by no means an expert, but I had to put [OR] to my file. As stated here

RewriteEngine on 
RewriteCond %{REQUEST_URI} !^.*robots.txt [OR]
RewriteCond %{REQUEST_URI} !^.*/static/.*
RewriteRule .* index.php [L]
2
  • As these are two "not" comparisons, anything - including robots.txt or /static/ - will match, if you use an [OR], which means everything gets rewritten. The goal here was to say "redirect everything EXCEPT robots.txt and /static/ to index.php", so I believe it was correct as written.
    – crb
    Jun 12, 2009 at 23:34
  • I had this problem recently - this gets messy real quick but this rule should work RewriteCond %{REQUEST_URI} !^.*(/static/)?(robots.txt)?$ [NC] Aug 4, 2009 at 1:20
0

I don't know if this applies to your application or not but couldn't you use the content of $_SERVER["REQUEST_URI"] instead?

1
  • 1
    I'm affraid not. When using mod_rewrite REQUEST_URI is changed to reflect the URI of the script instead of the one the client requested.
    – Paso
    Jun 23, 2009 at 10:21
0

Have you tried something like:

RewriteRule .* index.php [L,E=REQUEST_URL:$ENV{'REQUEST_URL'}]

Basically the idea is to pick it up from one environment and just shovel it along to the next one. Not sure it that'll work but can't hurt to try.

0

I believe we worked around this issue by upgrading Zend Framework, later versions don't depend on REQUEST_URL. It appears REQUEST_URL has different behaviour depending on which modules are installed. See this mailing-list thread

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .