Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confluence 6 Nginx

steffenbleul November 9, 2016

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

2 votes
Answer accepted
steffenbleul November 11, 2016

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

Disruptivation Help Desk
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 11, 2016

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/;
Andrew Laden
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 28, 2016

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

 

mharig April 4, 2017

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;
        }
}

 

 

mharig April 4, 2017

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

0 votes
gbatalski November 11, 2016

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

 

0 votes
Tam Tran
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 9, 2016

Sorry,

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

0 votes
steffenbleul November 9, 2016

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
Tam Tran
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 9, 2016

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
0 votes
steffenbleul November 9, 2016

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

0 votes
Tam Tran
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 9, 2016

@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?

0 votes
steffenbleul November 9, 2016

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?

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, confluence whiteboards, whiteboard templates, template contest, visual collaboration, atlassian learning, confluence community, brainstorming tools, agile planning, team productivity, confluence templates, share your template

Share Your Confluence Whiteboard Template for a Chance to Be Featured in the Product! 🏆

Want to leave your mark on Confluence? One winner will have their whiteboard design added into Confluence for all users to access! This is your chance to showcase your creativity, help others, and gain recognition in the Confluence community.

Share your template today!
AUG Leaders

Atlassian Community Events