0

I'm running a debian (jessie, 64-bit) server with nginx, jira and bitbucket installed. the url is referred to as "www.example.com"

First I installed jira, opened the setup site (http://example.com:8080) and finished the installation.

After that I created a virtual host "jira.example.com" in /etc/nginx/sites-available and created the corresponding symlink in /etc/nginx/sites-enabled:

server {
    listen 80;
    server_name jira.example.com;   
    location / {
        proxy_pass http://localhost:8080/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

this works fine. When I open http://jira.example.com it takes me to my jira-dashboard.

Then I installed bitbucket and openen the setup page on http://example.com:7990 which works, too.

I then decided to create another virtual host named "bitbucket.example.com":

server {
    listen 80;
    server_name bitbucket.example.com;  
    location / {
        proxy_pass http://localhost:7990/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

but this one doesn't work whereas jira works completely fine.

When I edited the include /etc/nginx/sites-enabled/*;-line in the nginx.conf to include /etc/nginx/sites-enabled/*.*; it redirects every http://example.com/* to http://example.com:7990 so I think I misconfigured nginx somehow.

2 Answers2

0

If http://example.com:7990 doesn't work it's obviously that nginx-proxy doesn't work too. Try to netstat -anp | grep 7990 to see if bitbucket listening connections. If not, fix bitbucket, not nginx.

  • Bitbucket works fine, I can access it when editing nginx.conf like described in the last paragraph and via wget on the server itself. Netstat -anp | grep 7990 returns that java (=bitbucket) is listening on this port – Zweistein2 Jan 11 '17 at 21:16
  • netstat -anp | grep 7990 returns: `tcp6 0 0 :::7990 :::* LISTEN 26631/java` – Zweistein2 Jan 12 '17 at 18:48
  • You wrote that http://example.com:7990 returns 404. It's not normal. If you try to connect to bitbucket forward, without nginx, and it returns 404, that means butbucket misconfigured. Try to turn nginx off and load http://example.com:7990. If it return 404, it means nginx is not guilty. There's no difference between `include .../*` and `include .../*.*`, so I think this is very uncommon error. – abr_stackoverflow Jan 12 '17 at 19:27
  • I fixed the `example.com:7990` problem, was caused by a adding a wrong port to the firewall rules (opened port 7900 instead of 7990). -> `example.com:7990` is working now, `bitbucket.example.com` is not. Seems to me that nginx doesn't load the corresponding files in the sites-available/enabled folders. Updated the question. – Zweistein2 Jan 12 '17 at 19:42
  • For clearance, the problem is completely related to nginx: /var/logs/nginx/access.log gets every `jira.example.com` but not a single `bitbucket.example.com`. `example.com:7990` was due to misconfigured firewall – Zweistein2 Jan 12 '17 at 19:48
0

You have a / at the end of proxy_pass statement. This means that all URIs are replaced with / when passed to the proxy. For example, http://bitbucket.example.com/testing will be proxied to http://localhost:7990/.

I don't know exactly how these applications use URLs, but I think they expect the complete URI.

This means you have to use proxy_pass http://localhost:7990; in your configuration, without the ending slash.

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58