Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Posted this on ServerFault but didn't get a response. Hoping I will have better luck on the Ubuntu site.

I have been trying to get this working the whole of today. I have a server which resolves to the domain example.com . This is running Apache2 and Tomcat 6. The requirement is to direct requests to example.com to apache2 and app.example.com to Tomcat. I know I have to do a VirtualHost proxy pass for this to work. Here are the settings on my server.

/etc/hosts file looks something like this     localhost localhost.localdomain example.com app.example.com 

I have two virtual host files for the different domains in /etc/apache2/sites-enabled

/etc/apache2/sites-enabled/example.com looks like this

<VirtualHost *:80>

  # Admin email, Server Name (domain name) and any aliases
  ServerAdmin webmaster@localhost
  ServerName  example.com
  ServerAlias www.example.com

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

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all

        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

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from ::1/128


/etc/apache2/sites-enabled/app.example.com file looks like this

<VirtualHost *:80>
  ServerName  app.example.com
  ServerAlias www.app.example.com

  ProxyPreserveHost On
  ProxyPass / http://localhost:8080/
  ProxyPassReverse / http://localhost:8080/
  SetEnv force-proxy-request-1.0 1
  SetEnv proxy-nokeepalive 1

mod_proxy and mod_rewrite are both enabled on the apache instance. I have a CNAME entry for both example.com and app.example.com. When accessing app.example.com, I get an 403 forbidden, saying I have no access to / on the server. What am I doing wrong?

share|improve this question
well, first of all you should post a link to the original question, so we can answer it there, or maybe at both places. Second, May I suggest a hack? In the <DocumentRoot> of app.example.com, give the webapp directory of tomcat6, ie /usr/share/tomcat6/webapps. PS: mod_proxy is useful for addresses like example.com/app which you can forward to internal ports. –  theTuxRacer Feb 7 '11 at 10:48
PS: I know its frustrating because I was trying to do the same. In the end, I kept port 8080 open, and directly goto www.example.com:8080 to the tomcat's webapp. –  theTuxRacer Feb 7 '11 at 10:51
I found this page for you, although is for CentOS, will work for any tomcat6+apache2 install. JUst make sure your proxy.conf file is in ../apache/mods-enabled/ folder. Link: library.linode.com/web-servers/apache/proxy-configuration/… –  theTuxRacer Feb 9 '11 at 7:45

2 Answers 2

I have similiar problem when I use such construction in virtual host definition:

ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/

In my case it start working when I point application:

  • these allow you to redirect such address: http://app.example.com/confluence

    ProxyPass /confluence/ http://localhost:8180/confluence/ 
    ProxyPassReverse /confluence/ http://localhost:8180/confluence/
  • these allow you to redirect such address: http://app.example.com to proper application

    ProxyPass / http://localhost:8180/confluence/ 
    ProxyPass / http://localhost:8180/confluence/
share|improve this answer


VirtualHost 'app.example.com:80'

instead of

VirtualHost '*:80'
share|improve this answer

Your Answer


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.