cptactionhank / docker-atlassian-jira

Atlassian JIRA Core wrapped in a Docker image
https://cptactionhank.github.io/docker-atlassian-jira
MIT License
622 stars 247 forks source link

Jira 7.3.5 port forwarding base url issue #46

Closed mojoritty closed 7 years ago

mojoritty commented 7 years ago

I used the cptactionhank configuration to Jira-software 7.3.5. Jira runs on port 8080 behind a nginx proxy. Since upgrading to version 7.3.5, Jira gives an error about the "Base URL for Gadgets" in the Support Tools settings menu. The result is that dashboard gadgets have incorrect names and no descriptions.

The issue seems to be that Jira tries to contact itself from inside the Docker image to retrieve gadget information and tries to use port 80 for this. Since Jira only listens on port 8080 inside the docker image the retrieval of information fails.

I was wondering if this should be fixed by routing port 80 to 8080 inside the docker Jira image using iptables. I tried to look inside, but it seems iptables is not available inside the docker image at the moment. Is this something that can be solved, and what could be the correct way to solve it?

I tried adding X_PROXY_PORT=8080 to the docker environment. This does seem to make the Gadgets name and discription appear correctly. However, Jira comes up with a slightly different error on the dachboard page stating "Dashboard Diagnostics: Mismatched URL Port". The Base URL error in the Support Tools menu is also still present.

I also tried the solution described in issue #20, setting the X_PROXY_NAME to docker and X_PROXY_PORT to 80, but this results in a different "Dashboard Diagnostics: Mismatched URL Hostname" error about a conflict between the docker host and the host described in the Base URL settings. It also doesn't seem to fix the faulty Gadget names.

cptactionhank commented 7 years ago

Can you tell more about what the baseUrl i configured to be? e.g. localhost would be an obvious bad idea.

Can you supply the commands used to create the containers this might be helpful as Well

mojoritty commented 7 years ago

I use the following docker-compose script for Jira, which results in the base url being jira.internal.mydomain.com

version: '2'

services:
  jira:
    container_name: jira
    restart: always
    image: cptactionhank/atlassian-jira-software:latest
    ports:
    - "8080:8080"
    volumes:
    - jira-data:/var/atlassian/jira
    - jira-logs-data:/opt/atlassian/jira/logs
    dns: 192.168.2.4
    expose:
    - "8080"
    hostname: jira.internal.mydomain.com
    network_mode: bridge
    environment:
    - VIRTUAL_HOST=jira.internal.mydomain.com

volumes:
  jira-data:
    external: true
  jira-logs-data:
    external: true

The nginx docker image is based on the jwilder docker image and uses the following docker-compose script

version: '2'

services:
  nginx:
    container_name: nginx
    restart: always
    image: jwilder/nginx-proxy
    ports:
    - "80:80"
    volumes:
    - /var/run/docker.sock:/tmp/docker.sock:ro
    - /srv/nginx-proxy/my_proxy.conf:/etc/nginx/conf.d/my_proxy.conf:ro
    dns: 192.168.2.4
    network_mode: bridge
cptactionhank commented 7 years ago

You JIRA base-url should point to your nginx frontend and not the JIRA container instance when forward proxying. It works the same way as if you were putting a regular JIRA behind a reverse proxy I would suggest you examine your configuration more closely.

Notice since I publish nginx on port 80 i can access the server using localhost and didn't want to create DNS og /etc/hosts entries. My base url in this case would be http://localhost.

Here is a working example using docker-compose and Docker for Mac

version: '3'
services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro

  jira:
    image: cptactionhank/atlassian-jira:latest
    environment:
      VIRTUAL_HOST: localhost
      CATALINA_OPTS: '-Xms1024m -Xmx1024m -XX:+UseG1GC -Datlassian.plugins.enable.wait=300'
      X_PROXY_NAME: localhost
      X_PROXY_PORT: 80
      X_PROXY_SCHEME: http
    ports:
      - 8080:8080
mojoritty commented 7 years ago

Thanks for your responses. I took a look at your example configurations and changed my Jira configuration, disabling the 'expose: "8080"' and 'hostname: jira.internal.mydomain.com' lines. Jira seems to handle all communications correctly now with the base url set to http://jira.internal.mydomain.com

Thanks for the help!