Nginx Configuration for Confluence Docker Image

Anil G August 5, 2019

Hi Team,

 

We have deployed the docker confluence server in the host and we are able to access the application on http://ip:port

Now we want to enable TLS encryption using Nginx.

May we know the Nginx Config to implement same.

 

 

--

Thanks,

Anil Kumar

1 answer

1 vote
Lei Wang
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 5, 2019

Hello Anil,

Here is how I set up Nginx in front of Confluence docker container:

  1. Pull the official Nginx docker container
    docker pull nginx
  2. You will need a docker network for confluence and nginx
    docker network create confserver
  3. Create the Confluence container with proxy tages
    docker run \
    --name="confluence" -d \
    -p 8090:8090 \
    -p 8091:8091 \
    -v ~/confluence-home/confluence-docker:/var/atlassian/application-data/confluence \
    -e CATALINA_CONNECTOR_PROXYNAME=test.myapp.com \
    -e CATALINA_CONNECTOR_PROXYPORT=443 \
    -e CATALINA_CONNECTOR_SCHEME=https \
    -e CATALINA_CONNECTOR_SECURE=false \
    --network confserver \
    atlassian/confluence-server
  4. Create the Nginx container in the same confserver network as Confluence
    docker run \
    --name="nginx" -d \
    -p 443:443 \
    --network confserver \
    -v ~/dockerdata/nginx/conf:/etc/nginx/conf.d/ \
    -v ~/dockerdata/nginx/ssl:/mnt \
    nginx
  5. Stop Nginx container, create the SSL certificate/key pair and default.conf then copy them to the host volume accordingly
    docker stop nginx
    cp confluence.key ~/dockerdata/nginx/ssl
    cp confluence.crt ~/dockerdata/nginx/ssl
    cp default.conf ~/dockerdata/nginx/conf

Now start Nginx and you should be able to access the Confluence container via port 443 https://test.myapp.com.

Lastly, here is my Nginx https configuration in default.conf:

server {
    listen          443;
    server_name     test.myapp.com;
    
    ssl                     on;
    ssl_certificate         /mnt/confluence.crt;
    ssl_certificate_key     /mnt/confluence.key;
    ssl_session_timeout     5m;
    ssl_protocols           TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers             HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;
    
    location / {
        client_max_body_size 100m;
        # We need FQDN name here <docker_container_name>.<docker_network_name>
        proxy_pass          http://confluence.confserver:8090/;
        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_set_header    X-Real-IP $remote_addr;
        #proxy_redirect      off;
    }

    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://confluence.confserver:8091/synchrony;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
     }
 }

Hope this information helps!

Best Regards.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events