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.

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

share|improve this question
1  
related post: serverfault.com/questions/23470/… –  Server Horror Jun 12 '09 at 12:46
    
Here is a similar problem [Fastcgi + mod_rewrite in Zend][1] [1]: serverfault.com/questions/423927/… –  user134535 Sep 3 '12 at 21:45

4 Answers 4

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]
share|improve this answer
    
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 '09 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] –  DisabledLeopard Aug 4 '09 at 1:20

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

share|improve this answer
    
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 '09 at 10:21

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.

share|improve this answer
up vote 0 down vote accepted

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

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.