I have JIRA and Nginx running on the same server with Nginx installed to serve as a reverse proxy. From what I learnt from various sources, in the server.xml file, I must add an address="127.0.0.1" attribute so that Tomcat does not listen to outside IPs. But once I add that to my 8080 and 8443 connectors, things stop working i.e., the JIRA site becomes inaccessible. Browser displays Connection refused / connection timed out errors.
Here is server.xml file configuration for Tomcat.
<Connector port="8080"
address="127.0.0.1"
maxThreads="150"
minSpareThreads="25"
connectionTimeout="20000"
enableLookups="false"
maxHttpHeaderSize="8192"
protocol="HTTP/1.1"
useBodyEncodingForURI="true"
acceptCount="100"
redirectPort="8443"
disableUploadTimeout="true"
proxyName=<FQDN>
proxyPort="80"/>
<Connector port="8443"
address="127.0.0.1"
SSLEnabled="true"
acceptCount="100"
clientAuth="false"
connectionTimeout="20000"
disableUploadTimeout="true"
enableLookups="false"
keyAlias=<value>
keystoreFile=<jks file>
keystorePass=<password>
keystoreType="JKS"
maxHttpHeaderSize="8192"
maxSpareThreads="75"
maxThreads="150"
minSpareThreads="25"
protocol="org.apache.coyote.http11.Http11Protocol"
scheme="https"
secure="true"
sslProtocol="TLS"
useBodyEncodingForURI="true"/>
and the Nginx server configuration in sites-enabled linked to sites-available folder -
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name <FQDN>;
location / {
proxy_pass http://127.0.0.1; #I have tried FQDN, real IP, :8080 suffix etc. but the response didn't change
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}
What is wrong in my approach? It's largely derived from https://confluence.atlassian.com/jirakb/integrating-jira-with-nginx-426115340.html except for adding the address attribute. The HTTPS connector block was derived (I guess it was auto-generated when I configured it) from Atlassian's standard SSL enabling instructions.
Update 21 April: Here is my nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Update 22 April I tried running curl -v FQDN and got this message in the error log. Terminal showed me 502 Bad gateway -
connect() failed (111: Connection refused) while connecting to upstream, client: <IP Address>, server: <FQDN>, request: "GET / HTTP/1.1", upstream: "http://<IP>:8080/", host: <FQDN>
ProxyPass
lines. Is there more to your nginx configuration that you haven't shown?proxy_pass http://jira-hostname:8080/jira;
to beproxy_pass http://127.0.0.1:8080/jira;
.