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 legacy site for a charity running on an old Apache 1.3 instance, behind Apache 2 running proxypass. When a request comes to example.com, Apache 2 sends it internally to localhost:8080 which works fine.

The problem:

example.com/blog/ works but example.com/blog (no trailing slash) does not. The URL it changes to in Chrome is example.com:8080/blog/ which doesn't exist.

The same is true for all other directories.

Apache 2:

<VirtualHost *:80>
    ServerName example.com
    ProxyPreserveHost On
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
</VirtualHost>

Apache 1:

NameVirtualHost *:8080
<VirtualHost *:8080>
    DocumentRoot /usr/www/html/
    ServerName example.com
    RewriteEngine on
    RewriteCond %{REQUEST_METHOD} !^(GET|POST|HEAD)$
    RewriteRule .* - [F]
</VirtualHost>

I thought a simple solution would be to add a rewriterule in either virtualhost but I've not had any success despite many attempts. I think a key issue is it's wrongly looking on example.com:8080 when the slash isn't there. It would be great if anyone can help me out, ask me any additional info that would be useful.

share|improve this question
    
A trace of exactly what gets sent back and forth between your Apaches, and Apache and the browser, in the erroneous case, would be handy. I still think there's a URL rewriting issue going on here somewhere. –  womble Jul 15 '11 at 13:35
    
@womble How would you recommend I produce a trace? I have checked the logs and nothing is appearing in access or error for either virtualhost. –  Ben Jul 15 '11 at 13:48
    
tcpdump would work. –  womble Jul 15 '11 at 22:18

1 Answer 1

I see no ProxyPassReverse or mod_proxy_html directives in your config; the lack of ProxyPassReverse, specifically, is likely to be the cause of your issue as the backend Apache is sending a redirect to the slashful URL, but has it's internal name in the Location: header, and without ProxyPassReverse the frontend Apache is just letting that internal URL leak.

mod_proxy_html is for the equivalent issues, but in HTML rather than HTTP headers. It's also worth using, unless you're really sure nobody's going to go putting a full URL in the HTML (which, for any dynamic webapp, is a bad bet).

share|improve this answer
    
Thanks - I have added ProxyPassReverse / localhost:8080 and restarted the server, unfortunately the same issue remains and it's trying to load up example.com:8080/blog/ when accessing example.com/blog - I've added the new line to original post. –  Ben Jul 15 '11 at 13:30

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.