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 am unable to configure apache2 frontend proxy to other servers and also serve apache2 content. My intent is to have apache2 serve some static content and some dynamic apps, both with domain names and those as sub-folders of the document root, and also serve some dynamic apps, both with domain names and without, proxied behind apache2. In other words, I want to do the following

Here is my (simplified) conf file with my intent and the unexpected exhibited behavior in the comments.

####################################################
# Default settings for http://my.server.edu/
####################################################
Listen 80
ServerName my.server.edu:80
DocumentRoot "/Users/me/Sites"

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

<Directory "/Users/me/Sites">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

####################################################
# Static content for http://my.server.edu/lib
####################################################
Alias /lib "/Users/me/Sites/lib"

# The server responds with a "502 Bad gateway" error
ScriptAlias /cgi-bin/ "/Users/me/cgi-bin/"

<Directory "/Users/me/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

####################################################
# Proxies
####################################################
ProxyRequests Off
<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>

# The following app should get their static content 
# from http://my.server.edu/lib, but the server responds
# with a "502 Bad gateway" error
####################################################
# http://my.server.edu/app1
####################################################
ProxyPass        /app1 http://127.0.0.1:5000
ProxyPassReverse /app1 http://127.0.0.1:5000

# The server responds with a "502 Bad gateway" error
# when serving static content
####################################################
# Virtual host http://vapp1.org
####################################################
<VirtualHost *:80>
    ServerName vapp1.org

    ####################################################
    # Static content for http://vapp1.org/lib
    ####################################################
    Alias /lib "/Users/me/Sites/lib"

    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    ProxyPass        / http://127.0.0.1:5001
    ProxyPassReverse / http://127.0.0.1:5001
</VirtualHost>

#####################################################
# Virtual host subdomain http://subapp.vapp1.org 
#####################################################
<VirtualHost *:80>
    ServerName subapp.vapp1.org 

    ####################################################
    # Static content for http://subapp.vapp1.org/lib
    ####################################################
    Alias /lib "/Users/me/Sites/lib"

    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    ProxyPass        / http://127.0.0.1:5002
    ProxyPassReverse / http://127.0.0.1:5002
</VirtualHost>

As you can see from above, if I have the virtual host segments in my conf file, the server responds with a "502 Bad gateway" error for everything that is supposed to come from http://my.server.edu.

However, if I remove the virtual host segments, all other apps work just fine.

I am sure I had this working on a previous machine, but now I am unable to reproduce that. What am I doing wrong?

share|improve this question

migrated from webmasters.stackexchange.com Sep 18 '11 at 0:08

This question came from our site for pro webmasters.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.