3

I'm trying to set up a reverse proxy with Apache and the Tomcat instance bundled with JIRA. I've followed the directions on the JIRA wiki to a T. The site is showing up just fine at http://ourdomain:8080/jira just fine, so I know that the Tomcat server.xml file has been set correctly per their instructions.

However, I cannot get the Apache reverse proxy to work, for reasons that elude me despite considerable reading.

I'm running Apache2.2 on Ubuntu with mod_proxy and mod_proxy_http enabled, of course. The default site works fine; my site configuration is just a modified version of that. Here's my jira virtual host configuration in /etc/apache2/sites-enabled/jira:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    ServerName ourdomain.com

    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>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log

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

    CustomLog ${APACHE_LOG_DIR}/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 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

    # JIRA Proxy Configuration
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    ProxyRequests       Off
    ProxyPreserveHost   On
    ProxyPass           /jira      http://ourdomain.com:8080/jira
    ProxyPassReverse    /jira      http://ourdomain.com:8080/jira
</VirtualHost>

When I hit the site in a browser, I get a 404 Not Found with the following (standard) text:

The requested URL /jira was not found on this server


Apache/2.2.22 (Ubuntu) Server at ourdomain.com Port 80

Meanwhile, the output from apachectl -S is:

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
     default server ourdomain.com.com (/etc/apache2/sites-enabled/000-default:1)
     port 80 namevhost ourdomain.com (/etc/apache2/sites-enabled/000-default:1)
     port 80 namevhost ourdomain.com (/etc/apache2/sites-enabled/jira:1)

So I can access the site just fine at ourcomain.com:8080/jira but not at ourdomain.com/jira.

Possibly that last line indicates the issue - should it be listening on port 8080 instead, and accordingly should I be changing the vhost entry above?

Clearly I have something wrong, but I'm not seeing it; my configuration appears to match that specified by the directions on the JIRA wiki precisely. Some help would be much appreciated. I've walked through several other answers here, and had no luck with those, either.

Chris Krycho
  • 137
  • 1
  • 7

2 Answers2

2

I have our JIRA set up in an almost identical manner although proxy through to a secure site.

The only difference I can spot between my config and yours is that I left the existing /etc/apache2/sites-enabled/000-default as is:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    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>

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

    ErrorLog ${APACHE_LOG_DIR}/error.log

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

    CustomLog ${APACHE_LOG_DIR}/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 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

But then added a new file /etc/apache2/sites-enabled/jira-mod_proxy which contained

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

SSLProxyEngine on
ProxyRequests       Off
ProxyPreserveHost On
ProxyPass           /jira       https://localhost:8443/jira
ProxyPassReverse    /jira       https://localhost:8443/jira

If you ignore the 8443 ports that I use for SSL then the only differences I can see are

  1. using localhost rather than a FQDN but that shouldn't matter because you can access your site at http://ourdomain:8080/jira so tomcat is obviously listening on your real IP address

  2. Having the <Proxy> configuration outside of the <VirtualHost> element.

So maybe the Proxy config needs to come outside of the virtual host settings?

Phil
  • 3,138
  • 1
  • 21
  • 27
  • Interesting -- so, just to be clear, then, your `sites-enabled/jira-mod_proxy` was _empty_ apart from the proxy info? I have a default setup just like that one. Combined with Shane Madden's answer below, I think that's the problem, which makes sense. – Chris Krycho Jan 24 '13 at 18:54
  • This deserves an upvote, though I currently lack the reputation to give it. I selected Shane's answer because it _answers_ most clearly, but the information here was invaluable. Thanks much for your help. – Chris Krycho Jan 24 '13 at 19:00
  • no problem and just to confirm yes, the jira-mod_proxy contains ONLY the info I give above – Phil Jan 25 '13 at 07:56
1

You have a ServerName ourdomain.com in /etc/apache2/sites-enabled/000-default, and a ServerName ourdomain.com in /etc/apache2/sites-enabled/jira. The 000-default one takes precedence because it's alphabetically first; your jira config is not being used.

Change the ServerName ourdomain.com line in the 000-default file, or if you're not using it, then simply a2dissite default.

Shane Madden
  • 112,982
  • 12
  • 174
  • 248
  • Ah, I see. So, we're using `ourdomain.com` as a landing page for a variety of apps (Confluence, JIRA, etc.), in which case `000-default` still needs to exist with that domain. Presumably, though, adding the proxy info either (a) in a separate `sites-enabled/jira` _alone_ or (b) adding it to the end of the original one should do the tric, right? – Chris Krycho Jan 24 '13 at 18:56
  • @ChrisKrycho Right, in that case you'll probably want to add your `Proxy` lines to the existing config. – Shane Madden Jan 24 '13 at 18:59
  • And then, presumably, similar `Proxy` setups for each of the other apps as we integrate them. Very good, this did it (I just tested). Thanks! – Chris Krycho Jan 24 '13 at 18:59