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.

This seems straightforward, but I can't make it work.

I have a pretty trivial webserver that only needs to do two things:

  1. example.com/status.html returns a local file (this works)
  2. example.com/atom redirects the contents of the firewalled server running on the same machine on port 4000

This didn't work:

RewriteRule ^$ http://localhost:4000

That redirected traffic back to localhost:4000 from the requestor's point of view (ie, on the client's machine).

My limited understanding of VirtualHost indicates that that's for something like atom.example.com, not example.com/atom

I think I have to use ProxyReverse, but I can't find the right combination.

UPDATE: Trying the ProxyPass/ProxyReverse suggestion given by Shane Madden produces this in the error log file:

[Thu Mar 15 11:59:15 2012] [error] (13)Permission denied: proxy: HTTP: attempt to connect to 127.0.0.1:4000 (localhost) failed
[Thu Mar 15 11:59:15 2012] [error] ap_proxy_connect_backend disabling worker for (localhost)
[Thu Mar 15 11:59:17 2012] [error] proxy: HTTP: disabled connection for (localhost)

(The local server is definitely running on 127.0.0.1:4000)

share|improve this question
    
RHEL 6.2 VM btw. Apache 2.2.15 –  Steve Bennett Mar 15 '12 at 0:58
add comment

1 Answer

up vote 2 down vote accepted

Don't use mod_rewrite unless you have a reason to do so.

Try this (put it in the <VirtualHost> block):

ProxyPass /atom http://127.0.0.1:4000/atom
ProxyPassReverse /atom http://127.0.0.1:4000/atom
share|improve this answer
    
At the moment I don't have a virtualhost block - will I need one? Or two? And if so, do they both start "VirtualHost *:80"? –  Steve Bennett Mar 15 '12 at 0:48
    
Are you sure you don't have one? Most sets of default configuration files do define one; how'd you install Apache? But - if you do not have one, then there's no need to add one - just add these directives to the server context. –  Shane Madden Mar 15 '12 at 0:51
    
Ok that didn't quite work: "service temporarily unavailable" for /atom (/blah returns 404 so it's doing something...) –  Steve Bennett Mar 15 '12 at 0:54
    
Shane: that section of httpd.conf only contains the commented out examples –  Steve Bennett Mar 15 '12 at 0:56
2  
Finally works. I needed to change a security setting: sudo /usr/sbin/setsebool -P httpd_can_network_connect 1 –  Steve Bennett Mar 15 '12 at 1:24
show 6 more comments

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.