Forums

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

Confluence in docker with nginx proxy

Chris Craig November 23, 2019

I'm trying to use the atlassian/confluence-server image to run confluence.  I want to use nginx as a reverse proxy so that it work with confluence.example.com

I have nginx configured, but what I'm having trouble with is the environment variables I need to specify in the docker-compose file to get it to work. 

Can somebody help?

3 answers

1 accepted

0 votes
Answer accepted
Gonchik Tsymzhitov
Community Champion
November 23, 2019

Hi! 

Could you clarify, please, nginx in docker or not ?

If not, when you run you can set host ip as upstream.

Because docker you run with mapping with some specific port, I hope

docker run -v /data/your-confluence-home:/var/atlassian/application-data/confluence --name="confluence" -d -p 8090:8090 -p 8091:8091 atlassian/confluence-server

 Cheers,

Gonchik

Chris Craig November 23, 2019

nginx IS also running in a container.

Gonchik Tsymzhitov
Community Champion
November 23, 2019

good.

 

Now nginx - work for confluence.example.com where upstream is http://192.168.1.102:8090 , 

1. ATL is correct. 

2. Base URL - confluence.example.com

Chris Craig November 23, 2019

Ok, I understand I have to set the Base URL, but I'm not sure where to do it.  The documentation doesn't mention that environment variable.

Chris Craig November 23, 2019

So, here's what I had to do to fix this.

1. I needed to set ATL_PROXY_NAME=confluence.example.com

2. I needed to set ATL_PROXY_PORT=443 (ssl is handled at the proxy level)

3. I needed to set ATL_TOMCAT_SCHEME=https

I had to muddle my way through the UI, removing the :8090 from the address at each click and change the Server Base URL to https://confluence.example.com

Everything is finally working.  Thanks so much for your help Gonchik! 

Like # people like this
Gonchik Tsymzhitov
Community Champion
November 23, 2019

You are welcome!

Like Vladislav Polyutkin likes this
0 votes
Olexiy Buyanskyy
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!
September 20, 2020

Hi, 

The idea is taken from

http://coffeetime.solutions/nginx-as-reverse-proxy-for-jira-and-confluence-on-docker/#Conclusion

server { 
   server_name wiki.yourhost.com;
# very important for installation, can be commented after!
   proxy_read_timeout 600s;

   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://127.0.0.1:8090;
   }
   location /synchrony {
       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://127.0.0.1:8091;
   }


   listen [::]:443 ssl; # managed by Certbot
   listen 443 ssl; # managed by Certbot
   ssl_certificate /etc/letsencrypt/live/wiki.yourhost.com/fullchain.pem; # managed by Certbot
   ssl_certificate_key /etc/letsencrypt/live/wiki.yourhost.com/privkey.pem; # managed by Certbot
   include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
   ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
   if ($host = wiki.yourhost.com) {
       return 301 https://$host$request_uri;
   } # managed by Certbot


       server_name wiki.yourhost.com;


   listen [::]:80;
   listen 80;
   return 404; # managed by Certbot


}

docker-compose.yml

version: '2' 

services:
 confluence:
   image: atlassian/confluence-server
   container_name: confluence
   networks:
     - confluencenet
   volumes:
     - /b100pro/atlassian/confluence/data:/var/atlassian/application-data/confluence
   ports:
     - 127.0.0.1:8090:8090
     - 127.0.0.1:8091:8091
   environment:
     - ATL_PROXY_NAME=wiki.yourhost.com
     - ATL_PROXY_PORT=443
     - ATL_TOMCAT_SCHEME=https

 postgresql:
   image: postgres:10.14-alpine
   container_name: confluence-postgres
   env_file:
     - .env
   networks:
     - confluencenet
   volumes:
     - /b100pro/atlassian/confluence/db:/var/lib/postgresql/data
   environment:
     - POSTGRES_USER=confluencedb
# password taken from .env file
     - POSTGRES_PASSWORD
     - POSTGRES_DB=confluencedb
     - POSTGRES_ENCODING=UTF8
     - POSTGRES_COLLATE=C
     - POSTGRES_COLLATE_TYPE=C


networks:
 confluencenet:
   external: false


 

0 votes
Chris Craig November 23, 2019

I should say, it "mostly" works.  When I hit confluence.example.com, I'm redirected to confluence.example.com:8090/...

If I remove the :8090, I get the confluence login page.  I have to keep removing the :8090 from the url.

Then, I see the error:

Confluence's base URL is set to http://192.168.1.102:8090 but you are accessing from https://confluence.example.com

Gonchik Tsymzhitov
Community Champion
November 23, 2019

Aha, let's proxy name in server.xml :) and rerun docker :)

Chris Craig November 23, 2019

Looking at the instructions here: https://hub.docker.com/r/atlassian/confluence-server

I've set the ATL_PROXY_NAME variable to confluence.example.com

version: "2"
services:
confluence:
container_name: confluence
image: atlassian/confluence-server
restart: unless-stopped
ports:
- 8090:8090
- 8091:8091
volumes:
- /opt/confluence/data:/var/atlassian/application-data/confluence
environment:
- ATL_PROXY_NAME=confluence.example.com

Like Gonchik Tsymzhitov likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events