Recently I was trying to configure apache2 to act as a proxy to mongrel (Ruby on Rails), so I added the following directives to my httpd.conf

<virtualhost *>

    ServerName test.example.com
    <proxy *="">
        Order allow,deny
        Allow from all
    </proxy>
    # Proxy directives
    ProxyPass /phpmyadmin ! # don't want proxy forwarding for phpMyAdmin
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
    ProxyPreserveHost on

    # Logfiles
    ErrorLog  /var/log/apache2/test.example.com.error.log
    CustomLog /var/log/apache2/test.example.com.access.log combined

</virtualhost>
</pre>
However, as soon as I used to restart apache after adding this code, it always threw 503 - Service Unavailable. The error log showed a number of lines like this one:
<pre>[Thu Jul 09 11:37:13 2008] [error] (13)Permission denied: proxy: HTTP: attempt to connect to 127.0.0.1:3000 (*) failed

In short it has to do something with permissions in SELinux which doesn’t allow httpd to connect to network and the solution is this command:

# /usr/sbin/setsebool httpd_can_network_connect 1

Thanks to the help found here and here.

Share This [?]

Comments

Leave a Reply




Close
E-mail It