Confluence 6 Nginx

Problem:

Confluence 6 behind Nginx:

  • Confluence is working.
  • The editor is not answering at all.

I am using the following nginx config:

server {

        listen       80;

        listen       [::]:80;

        server_name  confluence.yourhost.com;


		location /confluence {

          set $backend "http://confluence:8090";

          proxy_pass $backend;

          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;

        }

        location /synchrony {

          set $backend "http://confluence:8091/synchrony";

          proxy_pass $backend;

          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_http_version 1.1;

          proxy_set_header Upgrade $http_upgrade;

          proxy_set_header Connection "Upgrade";

        }
}

Nearly the same as in the Atlassian documentation: 

https://confluence.atlassian.com/confkb/how-to-use-nginx-to-proxy-requests-for-confluence-313459790.html

Is this really working or do I have (and how) to reconfigure synchrony?

8 answers

1 accepted

Accepted Answer
1 vote

Hello, I finally was able to get the configuration running!

I changed:

location /synchrony {
	set $backend "http://confluence:8091/synchrony";

to
location /synchrony {
	set $backend "http://confluence:8091";

My reverse proxy configuration:

location /synchrony {
          set $backend "http://confluence:8091";
          proxy_pass $backend;
          proxy_redirect http://confluence:8091 $scheme://$host/;
          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_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
        }


location / {
          set $backend "http://confluence:8090";
          proxy_pass $backend;
          proxy_redirect http://confluence:8090 $scheme://$host/;
          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;
}

My docker command and community image:

$ (Added confluence.yourhost.com to my /etc/hosts)
$ docker network create confluence
$ docker run -d --name confluence \
	--hostname confluence \
	--network confluence \
	-v confluencedata:/var/atlassian/confluence \
    -e "CONFLUENCE_PROXY_NAME=confluence.yourhost.com" \
    -e "CONFLUENCE_PROXY_PORT=80" \
    -e "CONFLUENCE_PROXY_SCHEME=http" \
    blacklabelops/confluence
$ docker run -d \
    -p 80:80 \
    --name nginx \
    --network confluence \
    -e "SERVER1SERVER_NAME=confluence.yourhost.com" \
    -e "SERVER1REVERSE_PROXY_LOCATION1=/synchrony" \
    -e "SERVER1REVERSE_PROXY_PASS1=http://confluence:8091" \
    -e "SERVER1REVERSE_PROXY_APPLICATION1=confluence6" \
    -e "SERVER1REVERSE_PROXY_LOCATION2=/" \
    -e "SERVER1REVERSE_PROXY_PASS2=http://confluence:8090" \
    -e "SERVER1REVERSE_PROXY_APPLICATION2=confluence" \
    blacklabelops/nginx

Confluence is accessible under: http://confluence.yourhost.com

I can confirm that the above works for SSL offloading as well smile

Most import bit is this:

proxy_redirect http://localhost:8090 $scheme://$host/;
AND
proxy_redirect http://localhost:8091 $scheme://$host/;

Note that if you use variables in the proxy_pass line, as in the example above, you also HAVE to set a resolver line. 

http://stackoverflow.com/questions/17685674/nginx-proxy-pass-with-remote-addr

http://www.nginx-discovery.com/2011/05/day-51-proxypass-and-resolver.html

 

Hi,

I am facing the same problem after upgrading to confluence 6.
I don't use a context path in my tomcat installation.
I copied your solution (instead of the "proxy_redirect" and "proxy pass" which I changed to the adress to 127.0.0.1 to get rid of the resolver, and I use SSL instead of port 80).

Unfortunately synchrony is not working. It hangs with the known error message "Loading the editor's taking longer than usual. Give it a few moments, then refresh your page if it still doesn't load. Speak to your Confluence admin if that doesn't fix it."

Am I missing something? Do I need a context path in Tomcat?

My nginx config. I removed most of the ssl parameters and changed the servername:

 

server {
        listen 80;
        server_name server.example.com;
        
        root /var/www/;
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
        
        rewrite        ^ https://$host$request_uri? permanent;

}

# HTTPS server
#
server {
        listen 443;
        server_name server.example.com;


        root /var/www/;
        access_log /var/log/nginx/ssl-access.log;
        error_log /var/log/nginx/ssl-error.log;
        
        location /synchrony {
                set $backend "http://127.0.0.1:8091";
                proxy_pass $backend;
                proxy_redirect http://127.0.0.1:8091 $scheme://$host/;
                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_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        }

        location / {
                set $backend "http://127.0.0.1:8090";
                proxy_pass $backend;
                proxy_redirect http://127.0.0.1:8090 $scheme://$host/;
                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;
        }
}

 

 

Never mind... Found out what I missed: The scheme, proxyName, proxyPort in tomcats server.xml. Works like a charme now. Thank you!

After looking into chrome developers console I have to adjust the question:

Synchrony is still requesting from url: http://localhost:8090/. How can I reconfigure synchrony?

0 votes

@Steffen Buehl,

I see that you use "confluence" as the hostname in the proxy_pass parameters "http://confluence:8091/confluence" and "http://confluence:8091/synchrony". If you are running Nginx on the same host of Confluence. Would you please replace "confluence" with "localhost" and try again?

Nginx and confluence are not on the same host! Confluence is reachable and accessable!

0 votes

Can you check if the Synchrony heartbeat URL is reachable via one of these 2 URL?

  1. http://confluence:8091/synchrony/heartbeat
  2. http://confluence:8091/heartbeat

There is no such page on Confluence 5 or 6...

I fixed the localhost issue by properly configuring the Confluence base url inside the administration page. Now the editor opens and I can press menu item buttons but everything else "gets stucked" and the contents of the page is not loaded.

0 votes

Sorry,

There was a typo in my comment. It's heartbeat not hearbeat. I updated the comment above.

Hi, i'm facing the same problem. If i disable internal confluence proxy and open the port 8091 to the clients, synchrony works. It is not an expected behaviour but it is a workaround, i think. With internal proxy my problem is that localhost:8091 is unreachable because of docker installation. So i need either to access the synchrony via internal proxy and specific hostname (eg. confluence:8091) or to configure the confluence to use a diffrent port for accessing context path /synchrony via nginx proxy and external url like http://confluence.my.company:80/synchrony.

My post is here: https://answers.atlassian.com/questions/44084117

Regards, Gena

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 09, 2018 in Confluence

Introducing Praecipio Consulting, an Atlassian Solution Partner

Hey there Community!  My name is Vannya Vallejo, the Channel Communication Specialist at Atlassian and I want to help Atlassian users like you learn about our Solution Partners and how they c...

389 views 0 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you