NGINX and Confluence
Asked by Tyler Hemingsen:

I have searched the documentation and many other's answers but I cannot get Nginx to work with Confluence.

Here is my /etc/nginx/conf.d/default.conf-

upstream tomcat {  
server localhost:8090 fail_timeout=0;  
}

<br />

server {  
listen confluence.hemi.haus:80;  
server_name confluence.hemi.haus;

listen 443 default ssl;  
# ssl on;  
ssl_certificate /usr/local/etc/nginx/ssl/nginx.crt;  
ssl_certificate_key /usr/local/etc/nginx/ssl/nginx.key;

ssl_session_timeout 5m;

ssl_protocols SSLv2 SSLv3 TLSv1;  
ssl_ciphers HIGH:!aNULL:!MD5;  
ssl_prefer_server_ciphers on;

location / {  
client_max_body_size 100m;  
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_pass http://localhost:8090;  
}  
location /synchrony {  
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_pass http://localhost:8091/synchrony;  
proxy_http_version 1.1;  
proxy_set_header Upgrade $http_upgrade;  
proxy_set_header Connection "Upgrade";  
}  
}

Here is my /opt/atlassian/confluence/conf/server/xml

\<Server port="8000" shutdown="SHUTDOWN" debug="0"\>  
\<Service name="Tomcat-Standalone"\>  
\<Connector port="8090" connectionTimeout="20000" redirectPort="8443"  
maxThreads="48" minSpareThreads="10"  
enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8"  
protocol="org.apache.coyote.http11.Http11NioProtocol"  
proxyName="confluence.hemi.haus" proxyPort="443" scheme="https"/\>

\<Engine name="Standalone" defaultHost="localhost" debug="0"\>

\<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="false" startStopThreads="4"\>  
\<Context path="" docBase="../confluence" debug="0" reloadable="false" useHttpOnly="true"\>  
\<!-- Logger is deprecated in Tomcat 5.5. Logging configuration for Confluence is specified in confluence/WEB-INF/classes/log4j.properties --\>  
\<Manager pathname="" /\>  
\<Valve className="org.apache.catalina.valves.StuckThreadDetectionValve" threshold="60" /\>  
\</Context\>

\<Context path="${confluence.context.path}/synchrony-proxy" docBase="../synchrony-proxy" debug="0" reloadable="false" useHttpOnly="true"\>  
\<Valve className="org.apache.catalina.valves.StuckThreadDetectionValve" threshold="60" /\>  
\</Context\>  
\</Host\>

\</Engine\>

\<!--  
To run Confluence via HTTPS:  
\* Uncomment the Connector below  
\* Execute:  
%JAVA_HOME%\\bin\\keytool -genkey -alias tomcat -keyalg RSA (Windows)  
$JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA (Unix)  
with a password value of "changeit" for both the certificate and the keystore itself.  
\* Restart and visit https://localhost:8443/

For more info, see <https://confluence.atlassian.com/display/DOC/Running+Confluence+Over+SSL+or+HTTPS>  
--\>  
\<!--  
\<Connector port="8443" maxHttpHeaderSize="8192"  
maxThreads="150" minSpareThreads="25"  
protocol="org.apache.coyote.http11.Http11NioProtocol"  
enableLookups="false" disableUploadTimeout="true"  
acceptCount="100" scheme="https" secure="true"  
clientAuth="false" sslProtocols="TLSv1,TLSv1.1,TLSv1.2" sslEnabledProtocols="TLSv1,TLSv1.1,TLSv1.2" SSLEnabled="true"  
URIEncoding="UTF-8" keystorePass="\<MY_CERTIFICATE_PASSWORD\>"/\>  
--\>  
\</Service\>  
\</Server\>

Running on Centos 7


Answers:
author: Lars Olav Velle
body: Hmm this looks pretty OK to me.

Have you tried proxypassing to 127.0.0.1 instead of localhost?

Perhaps try disabling selinux temporarily: setenforce 0

-Lars

comments: author: Tyler Hemingsen
body: setenforce 0 worked! Thank you so much.


author: Steven F Behnke
body: What does it mean, "Can't get it working?"

comments: author: Tyler Hemingsen
body: Sorry, 502 Bad Gateway error when connecting via Nginx.

I can browse directly to the 8090 port.