8

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)

1
  • RHEL 6.2 VM btw. Apache 2.2.15 Mar 15, 2012 at 0:58

1 Answer 1

10

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
11
  • 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"? Mar 15, 2012 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. Mar 15, 2012 at 0:51
  • Ok that didn't quite work: "service temporarily unavailable" for /atom (/blah returns 404 so it's doing something...) Mar 15, 2012 at 0:54
  • Shane: that section of httpd.conf only contains the commented out examples Mar 15, 2012 at 0:56
  • 3
    Finally works. I needed to change a security setting: sudo /usr/sbin/setsebool -P httpd_can_network_connect 1 Mar 15, 2012 at 1:24

You must log in to answer this question.

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