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'm trying to set up a basic virtual host to proxy all requests to test.local to a WEBrick server I have running on 127.0.0.1:8080 while keeping all requests to localhost going to my static files in /var/www. I'm running Ubuntu 10.04.

I have libapache2-mod-proxy-html installed and I have the module enabled with a2enmod proxy. I also have my virtual host enabled. However, whenever I go to test.local I always get a cryptic 500 server error and all my logs are telling me is:

[Thu Mar 03 01:43:10 2011] [warn] proxy: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

Here's my virtual host:

<VirtualHost test.local:80>
    LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
    ServerAdmin webmaster@localhost
    ServerName test.local
    ProxyPreserveHost On

    # prevents this folder from being proxied
    ProxyPass /static !

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    <Proxy *>
        Order allow,deny
        Allow from all
    </Proxy>
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

and here's my settings for mod_proxy:

<IfModule mod_proxy.c>
        #turning ProxyRequests on and allowing proxying from all may allow
        #spammers to use your proxy to send email.

        ProxyRequests Off

        <Proxy *>
        # default settings
                #AddDefaultCharset off
                #Order deny,allow
                #Deny from all
                ##Allow from .example.com

        AddDefaultCharset off
        Order allow,deny
        Allow from all
        </Proxy>

        # Enable/disable the handling of HTTP/1.1 "Via:" headers.
        # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
        # Set to one of: Off | On | Full | Block

        ProxyVia On
</IfModule>

Does anybody know what I'm doing wrong? Thanks

share|improve this question

2 Answers 2

up vote 29 down vote accepted

Looks like you're not loading the mod_proxy_http module (which is needed to proxy to HTTP servers). I don't have Ubuntu 10.04 in front of me, but IIRC it's something like:

sudo a2enmod proxy_http
share|improve this answer
    
I have both proxy_http and proxy_html enabled and restarted apache but now I'm getting a 503 error. Here's the logs from right after I restarted with 3 refreshes on firefox: –  SevenProxies Mar 3 '11 at 20:28
    
[Thu Mar 03 12:25:29 2011] [error] (111)Connection refused: proxy: HTTP: attempt to connect to 127.0.0.1:8080 (localhost) failed [Thu Mar 03 12:25:29 2011] [error] ap_proxy_connect_backend disabling worker for (localhost) [Thu Mar 03 12:26:05 2011] [error] proxy: HTTP: disabled connection for (localhost) [Thu Mar 03 12:26:10 2011] [error] proxy: HTTP: disabled connection for (localhost) –  SevenProxies Mar 3 '11 at 20:28
    
Actually, all of a sudden it started working. Thank you. –  SevenProxies Mar 3 '11 at 20:41
1  
Thanks, this worked for me. –  Radar Feb 28 '13 at 15:39
    
In my case, proxy_ajp was missing (we use AJP to connect with tomcat). –  Thomas Ferris Nicolaisen Jun 16 at 11:54

The above answer didn't help for me as I was receiving the same error as in the author's comment in the selected answer. However, I did find the following post and change which solved my problem:

sudo /usr/sbin/setsebool -P httpd_can_network_connect 1

Source: http://allscm.com/archives/apache2-proxy-disabled-connection-on-localhost.html

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.