Apache as Proxy for Tomcat with Subdomain

I am running Confluence (and Jira) as WARs on a Tomcat instance on Ubuntu. The application is accessible via http://localhost:8080/confluence. I would like to configure apache as a proxy to allow public access via http://confluence.<servername>.de. Following the instructions on https://confluence.atlassian.com/display/DOC/Using+Apache+with+mod_proxy#UsingApachewithmod_proxy-complex I did the following steps:

  • appended the attributes proxyName="confluence.<servername>.de" andproxyPort="80" to the Connector element in /var/lib/tomcat7/conf/server.xml.
  • Defined a virtual host in /etc/apache2/sites-enabled/confluence.conf with the following content:
&lt;VirtualHost *:80&gt;
    ServerName confluence.&lt;servername&gt;.de

    ProxyRequests Off
    ProxyPreserveHost On

    &lt;Proxy *&gt;
        Order deny,allow
        Allow from all
    &lt;/Proxy&gt;

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

    ProxyHTMLURLMap / /confluence/

    &lt;Location /&gt;
        Order allow,deny
        Allow from all
    &lt;/Location&gt;
&lt;/VirtualHost&gt;

With this configuration I cannot invoke http://localhost:8080/confluence due to this (wget) output:

--2014-12-23 08:38:13--  http://localhost:8080/confluence
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8080... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://confluence.&lt;servername&gt;.de/confluence/ [following]
--2014-12-23 08:38:13--  http://confluence.&lt;servername&gt;.de/confluence/
Resolving confluence.&lt;servername&gt;.de (confluence.&lt;servername&gt;.de)... 92.51.163.197
Connecting to confluence.&lt;servername&gt;.de (confluence.&lt;servername&gt;.de)|92.51.163.197|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2014-12-23 08:38:13 ERROR 404: Not Found.

If I remove the attributes proxyName and proxyPort this access is possible. However, the invocation via http://confluence.<servername>.de still yields errors. The output of Apache log suggests that the URL rewrite is corrupt:

[Tue Dec 23 08:50:47.952647 2014] [authz_core:debug] [pid 24715:tid 140609413170944] mod_authz_core.c(828): [client 37.201.226.149:11808] AH01628: authorization result: granted (no directives)
[Tue Dec 23 08:50:47.952809 2014] [proxy:debug] [pid 24715:tid 140609413170944] mod_proxy.c(1104): [client 37.201.226.149:11808] AH01143: Running scheme http handler (attempt 0)
[Tue Dec 23 08:50:47.952838 2014] [proxy:debug] [pid 24715:tid 140609413170944] proxy_util.c(2020): AH00942: HTTP: has acquired connection for (localhost)
[Tue Dec 23 08:50:47.952851 2014] [proxy:debug] [pid 24715:tid 140609413170944] proxy_util.c(2072): [client 37.201.226.149:11808] AH00944: connecting http://localhost:8080/confluence to localhost:8080
[Tue Dec 23 08:50:47.953069 2014] [proxy:debug] [pid 24715:tid 140609413170944] proxy_util.c(2206): [client 37.201.226.149:11808] AH00947: connected /confluence to localhost:8080
[Tue Dec 23 08:50:47.953176 2014] [proxy:debug] [pid 24715:tid 140609413170944] proxy_util.c(2483): (111)Connection refused: AH00957: HTTP: attempt to connect to [::1]:8080 (localhost) failed
[Tue Dec 23 08:50:47.953277 2014] [proxy:debug] [pid 24715:tid 140609413170944] proxy_util.c(2610): AH00962: HTTP: connection complete to [::1]:8080 (localhost)
[Tue Dec 23 08:50:47.956860 2014] [proxy:debug] [pid 24715:tid 140609413170944] proxy_util.c(2035): AH00943: http: has released connection for (localhost)
[Tue Dec 23 08:50:47.988123 2014] [authz_core:debug] [pid 24715:tid 140609402681088] mod_authz_core.c(828): [client 37.201.226.149:11808] AH01628: authorization result: granted (no directives)
[Tue Dec 23 08:50:47.988231 2014] [proxy:debug] [pid 24715:tid 140609402681088] mod_proxy.c(1104): [client 37.201.226.149:11808] AH01143: Running scheme http handler (attempt 0)
[Tue Dec 23 08:50:47.988250 2014] [proxy:debug] [pid 24715:tid 140609402681088] proxy_util.c(2020): AH00942: HTTP: has acquired connection for (localhost)
[Tue Dec 23 08:50:47.988264 2014] [proxy:debug] [pid 24715:tid 140609402681088] proxy_util.c(2072): [client 37.201.226.149:11808] AH00944: connecting http://localhost:8080/confluenceconfluence/ to localhost:8080
[Tue Dec 23 08:50:47.988277 2014] [proxy:debug] [pid 24715:tid 140609402681088] proxy_util.c(2206): [client 37.201.226.149:11808] AH00947: connected /confluenceconfluence/ to localhost:8080
[Tue Dec 23 08:50:47.990134 2014] [proxy:debug] [pid 24715:tid 140609402681088] proxy_util.c(2035): AH00943: http: has released connection for (localhost)

Am I missing anything? By the way, if I adjust the virtual host configuration in a way that the URL http://<servername>.de/confluence is used as a proxy everything works fine.

Any suggestion would be greatly appreciated.

2 answers

0 vote

Hi Andreas, 

Also, I could see you are getting code 302. It isn’t an error, but when  it try redirect from localhost to confluence.servername.de, it show us a 404 return, which means the destination wasn’t found. It might happens for many reasons.  You can have a proxy blocking, the IP is wrong or the DNS address is not answering your requests. 

So, instead of you set up localhost on your vhost, could you try to use the URL (something like: confluence.servername.de)?

You don’t need to remove the attributes proxyName and proxyPort from server.xml. It needs to be setup as you can see on the documentation you mentioned. 

Another thing that might be a problem is the connection refused on the IPV6 (|::1|:8080... failed: Connection refused.). For troubleshoot purposes, it would be a good idea you try to disable the IPV6 to see if it works. 

In addition, can you check if you have the modSecurity enable? It may be blocking your redirections. 

 

Hope it helps.

Renato Rudnicki

Hi Renato, thanks for the suggestions. Meanwhile, I changed by server configuration in a way that fulfills my needs, but as it is quite different from the one described above, I cannot actually say if your suggestions would have helped, too. Thanks anyway!

0 vote

Hello Andreas,

Thank you for your question.

I would kindly suggest you on setting it up as per following:

  • edit path under <confluence-install>/conf/server.xml:

    &lt;Context path="" docBase="../confluence" ...
  • edit the vhosts created as per following:

    &lt;VirtualHost *:80&gt;
        ServerName confluence.&lt;servername&gt;.de
     
        ProxyRequests Off
    	ProxyPreserveHost On
    
    
        &lt;Proxy *&gt;
            Order deny,allow
            Allow from all
        &lt;/Proxy&gt;
     
        ProxyPass / http://localhost:8090/
        ProxyPassReverse / http://localhost:8090/
    
        &lt;Location /&gt;
            Order allow,deny
            Allow from all
        &lt;/Location&gt;
    &lt;/VirtualHost&gt;

    In the example above I have used 8090 as port number to Confluence. It seems in your case you have changed it to 8080, so please, remember to do the appropriated changes under <confluence-install>/conf/server.xml to match the vhosts settings.

  • hit Confluence on your web browser as per following:

    http://confluence.&lt;servername&gt;.de

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

Hi Rafael, thanks for the recommendations. I'm afraid, my description was a little imprecise. I intended to use both Jira and Confluence on the the same tomcat instance. That made it neccessary to configure a more difficult vhost configuration than you suggested in your answer. However, I decided to use the standalone variants of the applications even though I have two Tomcat instances to maintain now. Regarding my original issue stated in the post, however, I cannot consider your answer as useful as it does not hit the point, sorry ;-)

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Friday in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

264 views 11 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you