dockerdocker-swarmtraefikbitbucket-serverdocker-stack

How to change the context path of bitbucket-server in docker mode


I am looking for a way to change the context path of bitbucket-server in docker mode, because I am trying to run it behind a traefik reverse proxy and want to use my domain for multiple applications (one for each path):

I want my bitbucket-server to be served over https://my.domain.name/bitbucket, and my jira over https://my.domain.name/jira... etc

I already found a solution for other Atlassian products (jira, servicedesk and confluence) using the reverse proxy setting ATL_TOMCAT_CONTEXTPATH, that environment param is not described in the bitbucket-server docker hub page.

My docker swarm stack looks like this:

version: '3'

services:

  bitbucket-server:
    image: atlassian/bitbucket-server:6.7
    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.bitbucket-server.entryPoints=websecure"
        - "traefik.http.routers.bitbucket-server.rule=Host(`my.domain.name`) && PathPrefix(`/bitbucket`)"
        - "traefik.http.services.bitbucket-server.loadbalancer.server.port=7990"
        - "traefik.http.routers.bitbucket-server.tls=true"
        - "traefik.http.routers.bitbucket-server.tls.certresolver=letsencrypt"
        - "traefik.http.routers.bitbucket-server.tls.domains=my.domain.name"
    environment:
      - ATL_PROXY_NAME=traefik.my.domain.name
      - ATL_PROXY_PORT=443
      # next line didn't work ! 
      # - ATL_TOMCAT_CONTEXTPATH=/bitbucket
    volumes:
      - bitbucket_data:/var/atlassian/application-data/bitbucket
    networks:
      - local
      - public-proxy
    labels:
      - description= "Bitbucket"
      
  jira-software:
    image: atlassian/jira-software:8.5
    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.jira-software.entryPoints=websecure"
        - "traefik.http.routers.jira-software.rule=Host(`my.domain.name`) && PathPrefix(`/jira`)"
        - "traefik.http.services.jira-software.loadbalancer.server.port=8080"
        - "traefik.http.routers.jira-software.tls=true"
        - "traefik.http.routers.jira-software.tls.certresolver=letsencrypt"
        - "traefik.http.routers.jira-software.tls.domains=my.domain.name"
    volumes:
      - jira_software_data:/var/atlassian/application-data/jira
    environment:
      - ATL_PROXY_NAME=traefik.my.domain.name
      - ATL_PROXY_PORT=443
      # next line did work !
      - ATL_TOMCAT_CONTEXTPATH=/jira
      - ATL_TOMCAT_SCHEME=https
      - ATL_TOMCAT_SECURE=true
    networks:
      - local
      - public-proxy
    labels:
      - description= "Jira Software"
  
  jira-servicedesk:
    image: atlassian/jira-servicedesk:4.5
    
    # ... Same as jira-software

  confluence:
    image: atlassian/confluence-server:7.1  
    
    # ... Same as jira-software
    
networks:
  local:
  public-proxy :
    external: true

volumes:
  servicedesk_data:
  confluence_data:
  jira_software_data:
  bitbucket_data:

Solution

  • Context path can be configured from bitbucket.properties by adding this line

    server.context-path=/bitbucket
    

    In a docker environment, you can mount your bitbucket properties file to your container so it replaces the default one

    volumes:
      - YOUR_BITBUCKET_PROPERTIES:<Bitbucket home directory>/shared/bitbucket.properties