The content on this page relates to platforms which are not supported for Confluence. Consequently, Atlassian can not guarantee providing any support for the steps described on this page. Please be aware that this material is provided for your information only and that you use it at your own risk. |
Introduction
The Apache web server is often used in front of an application server to improve performance in high-load environments. Mod_proxy simply redirects requests for certain URLs to another web server, so it typically requires no additional configuration on the application server.
This page documents a very common configuration request: configuring JIRA and Confluence on two Apache virtual hosts, running on different application servers. This is just a special case of mod_proxy configuration.
You can use virtual hosts in your application server if you want to run JIRA and Confluence on the same application server. There is a sample configuration for Tomcat you can use after configuring Apache.
Apache configuration
For this configuration to work properly, the application paths must be the same on both the application servers and the web server. For both JIRA and Confluence below, this is /.
JIRA external URL | |
|---|---|
JIRA application server URL | |
Confluence external URL | |
Confluence application server URL |
Add the following to your Apache httpd.conf:
Points to note:
- ProxyPass and ProxyPassReverse directives send traffic from the web server to your application server.
- The application path is the same on the application server and on the web server (both are /).
- Because the above configuration uses name-based virtual hosting, you must configure your DNS server to point both names (jira.example.com, confluence.example.com) to your web server.
More information
For different ways to configure mod_proxy, see Using Apache with mod_proxy.
If you use Tomcat, mod_jk provides a different way of connecting Apache via AJP. You can also use the above configuration with just one application server if you use Tomcat's virtual hosts.







16 Comments
Hide/Show CommentsMar 22, 2007
Andy Jones
Hi
I'm wondering if anyone else has set up a single confluence Space to look like an Apache vhost...
I'm successfully running Confluence 2.3.1 (listening on localhost:8080) behind Apache 2.0.52 (listening on *:80) with the following directives.
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
This shows the whole confluence site, and works fine.
I've then set up a second vhost, and proxy directed it to a single space, but ran into problems that various resources on the page are not in the space. So I added a number of extra proxy config lines. To wit:
ProxyPass /decorators http://localhost:8080/decorators
ProxyPass /download http://localhost:8080/download
ProxyPass /images http://localhost:8080/images
ProxyPass /plugins http://localhost:8080/plugins
ProxyPass /display/downtown http://localhost:8080/display/SPACENAME/
ProxyPass / http://localhost:8080/display/SPACENAME/
ProxyPassReverse / http://localhost:8080/display/SPACENAME/
It basically seems to be working, as in the links work, which is good, but the ProxyPassReverse URL rewriting doesn't seem to be working - URLs show up as http://vhost.domain.name/display/SPACENAME/PageName.
The other thing is that links to pages in other spaces don't work. Obviously I have a lot to learn about apache's proxy/rewriting modules...
Just wondering if anyone else has dont this before, and what their solution was..
cheers - andy
Jun 26, 2007
Andy Jones
I probably should add that I ended up resolving this.
Confluence runs in the back-end, listening on localhost (127.0.0.1) port 8080.
An Apache sits in front of it, listening on port 80, configured with a number of virtual hosts (vhosts).
One vhost, known as "confluence.domain.name", just proxies all content, with the "ProxyPass" and "ProxyReverse" directives above. We use it for our internal updates etc.
Another vhost, which is our public web site, has a series of mod_redirect RewriteRules, which catch references to known Confluence content, and run it through a proxy. As a result, anything which does not match a redirect rule, is served by the vhost from it's DocumentRoot. This means that we can have a single web site which contains our Confluence content, plus non-confluence content, like PHP applications etc.
I obtained the Confluence redirections by checking through the Apache access logs and error logs. The downside is that if new versions of confluence add new URLs, they won't work until I spot them in our Apache vhost error log. I ended up with about 40 Redirections. I could have used less specific wildcards to reduce that number, but it's a matter of personal taste.
The vhost has stuff like:
ProxyPassReverse / http://localhost:8080/
RewriteEngine On
RewriteRule ^(/+)(display/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(admin/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(bootstrap/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(dashboard/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(dwr/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(display/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(decorators/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(download/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(exportword)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(includes/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(images/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(label/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(labels/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(pages/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(plugins/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(renderer/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(s/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(setup/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(spaces/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(styles/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(themes/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(users/)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(addpersonalspacetofavourites.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(addprofiletofavourites.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(administrators.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(attachmentnotfound.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(browsepeople.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(colourpicker.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(dopeopledirectorysearch.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(dosearchsite.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(forgotusername.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(forgotuserpassword.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(fourohfour.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(homepage.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(login.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(logout.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(peopledirectory.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(removepersonalspacetofavourites.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(removeprofilefromfavourites.action)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(editpage-javascript)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(labels-javascript)(.*) http://localhost:8080/$2$3 [P,QSA,L]
RewriteRule ^(/+)(wysiwyg-javascript)(.*) http://localhost:8080/$2$3 [P,QSA,L]
I'm not sure if the QSA is necessary. I'm also not sure if the (/+) is needed - I had some problems with some URLs which had "//" in them.
On the confluence General Admin page, I changed the Server Base URL from http://localhost:8080/ to the public name of my site, since I found that sometimes localhost URLs were leaking out. I also modified the Confluence 404 page (edit the confluence/WEB-INF/classes/com/atlassian/confluence/core/ConfluenceActionSupport.properties) and customised the Apache vhost 404 error page (via the HTTP_NOT_FOUND.html.var file).
I hope this helps someone else.
Edit: forgot to un-wikify the rules...
andy
Oct 18, 2011
Anonymous
We have confluence set up behind an Apache Virtual Host doing SSL. We had some issues with strange URI escaping issues, particularly around redirects at the login page. (We also saw a similar issue with Jira, where it would appear to double-escape request arguments, such as when you are setting up Trust between Jira and Confluence.)
Our working Apache config is below.
<VirtualHost *:80>
DocumentRoot /srv/confluence
ServerName wiki.example.com
ServerAlias wiki.example.com
RewriteEngine On
RewriteRule ^/(.*) https://%\{SERVER_NAME}/$1 R,L
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /srv/confluence
ServerName wiki.example.com
ServerAlias wiki.example.com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 192.168.0.0/255.255.0.0
</Location>
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPreserveHost On
LogLevel info
ErrorLog /var/log/apache2/wiki-error.log
CustomLog /var/log/apache2/wiki-access.log combined
RewriteEngine On
RewriteLog /var/log/apache2/wiki-rewrite.log
RewriteLogLevel 0
RewriteRule ^/server-status$ /server-status$1 L
RewriteRule ^/(.*)$ http://127.0.0.1:8080/$1 P,QSA,L
ProxyPassReverse / http://127.0.0.1:8080/
SSLEngine on
SSLProtocol all
SSLCertificateFile /etc/apache2/ssl/yourcert.crt
SSLCertificateKeyFile /etc/apache2/ssl/yourkey.key
</VirtualHost>
Mar 26, 2008
Anonymous
The not busted formatting:
<VirtualHost *:80> DocumentRoot /srv/confluence ServerName wiki.example.com ServerAlias wiki.example.com RewriteEngine On RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L] </VirtualHost> <VirtualHost *:443> DocumentRoot /srv/confluence ServerName wiki.example.com ServerAlias wiki.example.com <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Location /server-status> SetHandler server-status Order Deny,Allow Deny from all Allow from 127.0.0.1 192.168.0.0/255.255.0.0 </Location> <Proxy *> Order allow,deny Allow from all </Proxy> #ProxyRequests Off ProxyPreserveHost On LogLevel info ErrorLog /var/log/apache2/wiki-error.log CustomLog /var/log/apache2/wiki-access.log combined RewriteEngine On RewriteLog /var/log/apache2/wiki-rewrite.log RewriteLogLevel 0 RewriteRule ^/server-status$ /server-status$1 [L] RewriteRule ^/(.*)$ http://127.0.0.1:8080/$1 [P,QSA,L] ProxyPassReverse / http://127.0.0.1:8080/ SSLEngine on SSLProtocol all SSLCertificateFile /etc/apache2/ssl/example.crt SSLCertificateKeyFile /etc/apache2/ssl/example.key </VirtualHost>May 15, 2009
Hellmut Adolphs
Your problem is due to URI re-encoding during the rewrite...
I went through the same thing, ended up resolving it by using the 'noescape|NE' (no URI escaping of output) flag in mod rewrite for example:
That would secure every action, by using NE it stops url encoding the % symbol, resolving the issue with the re-encoded parameters that had special symbols in them, such as os_destination=%2Fhomepage.action which was being re-encoded to os_destination=%252Fhomepage.action
We should have a page in here that is only for configuring confluence behind apache 2 using SSL and mod-proxy ...
Mar 27, 2008
Choy Li Tham
Hi,
May i know if you still encountering the problem? If that is the case, please raise a support ticket at here for further investigation.
Regards,
Choy Li
Jan 07, 2009
Anonymous
Not bad but not perfect.
Hmm... I followed an instruction that I found elsewhere on the web which advised:
I then discovered that when I came across any javascript history.go(-1) links (such as when returning from an Issue's Printable display page) that I was sent to http://localhost:8080/jira/...
Using your solution above is better but not perfect because it introduces port 8080 into the URL, which not only makes the URL more ugly but also means the user is browing directly onto TOMCAT rather than going though apache.
Does anyone have the perfect solution?
Paul
Feb 17, 2009
Arie Murdianto
Hi,
You can change the port 8080 to use port 80 instead. Thus, you dont need to use 8080 to access your Confluence. Also, you need to change the configuration of https.conf accordingly. If my explanation does not answer your question. Please feel free to raise a support ticket to:
* http://support.atlassian.com
Cheers,
Apr 23, 2011
Anonymous
wouldn't this require running confluence as root?
This would be unacceptable for most, if not all environments.
Apr 27, 2009
Alexander Brill
I've set up Confluence to run together with some other webapps on my Tomcat. Direct access to confluence is on http://localhost:8080/confluence.
However, I am having some difficulty of setting up an apache virtual host. If I now go to http://confluence.example.com I am redirected to http://confluence.example.com/*confluence\* (http://confluence.example.com/*confluence*). I would like to strip "confluence" from the url so that it seems that I have it on the root context.
Jan 03, 2011
İshak Teyran
I am a newbie to both Tomcat and Apache. I have set the virtual hosts as described above. And JIRA works fine when browse the URL jira.agmlab.com. However when i try to access Confluence with confluence.agmlab.com the page comes in plain html, i can login and browse pages but there is no css or js so that my confluence pages look very ugly. what can possibly cause this and how to fix this?
here is my virtual hosts definitions :
and i added
127.0.0.1 jira.agmlab.com
127.0.0.1 confluence.agmlab.com
to my hosts file (i am using Win Server 2008 OS).
here is part of the error log from Apache access.log file :
I can see the pages properly with js and css and images when i use confluence with URL localhost:8081/confluence.
Mar 23, 2011
Anonymous
Hi,
I am having the same setup, and have not gotten it to work. could you please share with me about your result?
Thanks,
Tina
Jan 25, 2012
Anonymous
It's working for JIRA because JIRA and APACHE have the same path / :
While for your confleunce you have /confluence path of the application and / path for APACHE:
So to fix it you have to modify your application's path in confluence_installation_files/conf/server.xml
<Context path="/confleunce"
remove the confleunce; you should have <Context path="/"
and then modify your APACHE conf also by removing the /confleunce/ from the proxyPass, it should become :
Don't forget to restart apache and confleunce
Best Regards,
Jun 22, 2011
Dave Thomas
For people who use HTTPS to access the reverse proxy and plain HTTP for Confluence: If you're still having problems with the login page re-encoding os_destination=%252Fhomepage.action, you might try the following tomcat connector settings for Confluence. This resolved the problem for us:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" scheme="https" proxyName="myproxy.mydomain.com" proxyPort="443" />Nov 23, 2011
Anonymous
don´t miss: ProxyPassReverseCookiePath /confluence /
(path to the context path)
Jan 13, 2012
Anonymous
Hi,
I have running crowd, jira and confluence. If I access local via IP-Adress (192.x.x.x), SSO is working perfectly.
But if I would access via external URL, SSO doesn't work with the configuration described in this wiki-page.
If I would set the "SSO Domain" to .example.com, Crowd always response with "The supplied domain is invalid."
The solution:
add "ProxyPreserveHost On" on every virtual host configured.
bye
Robert
Add Comment