Configuring nginx as a reverse-proxy for JIRA

We're running nginx as a reverse-proxy for serving several of our applications. Adding JIRA to the mix was mostly smooth and there are just two files to edit.

nginx

First you'll need to update your nginx configuration to proxy JIRA. The default port is 8080 so the configuration looks like this:

location ^~ /jira {  
  proxy_redirect off;
  proxy_set_header X-Forwarded-Host $host;
  proxy_set_header X-Forwarded-Server $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Authorization ""; #
  proxy_pass http://localhost:8080/jira;
}

One important directive to note here is proxy_set_header Authorization "". We need to send an empty Authorization to JIRA otherwise your application will return a 403 http error.

JIRA

Look for your server.xml file located in the /conf folder and cd into it. I suggest making a backup first.

$ sudo cp server.xml server.xml.bak

Find the line near:

<Connector acceptCount="100"  
  connectionTimeout="20000"
  disableUploadTimeout="true"
  enableLookups="false"
  maxHttpHeaderSize="8192"
  maxThreads="150"
  minSpareThreads="25"
  port="8080"
  protocol="HTTP/1.1"
  redirectPort="8443"
  useBodyEncodingForURI="true"
/>

and append the following:

scheme="http"  
proxyName="example.com"  
proxyPort="80"  

so that it looks like:

<Connector acceptCount="100"  
  connectionTimeout="20000"
  disableUploadTimeout="true"
  enableLookups="false"
  maxHttpHeaderSize="8192"
  maxThreads="150"
  minSpareThreads="25"
  port="8080"
  protocol="HTTP/1.1"
  redirectPort="8443"
  useBodyEncodingForURI="true"
  scheme="http"
  proxyName="example.com"
  proxyPort="80"
/>

Go back into the /bin folder and execute the start-jira.sh script. If you want to watch the server status, you can tail the output log:

$ tail -f logs/catalina.out

Write comments below if you're having any issues.

Alex Ho

Alex is the Lead Developer at NYCEDC working as a front-end/back-end developer and sysadmin. He has a Graphic Design certification from NYU and is a UX practitioner.