Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket server is redirecting to localhost:7990 behind nginx reverse proxy

Michael_Plautz May 14, 2020
  • I have Bitbucket server 7.1.1
  • Running on CentOS 7
  • Running behind an nginx reverse proxy
  • Running on port 7990
  • With the baseUrl configured within the settings admin panel

I can access bitbucket through my the web interface by going to the reverse proxied address git.domain.com. When I do, it asks for my login, and then upon successful login, I am redirected to http://localhost:7990.

Then (since I am an admin) I see a warning in the upper right corner that there is a "Base URL mismatch", but when I go to set the base URL, it is already set to git.domain.com.

Finally, when I go to create a new repository and get its URL to clone it for the first time, I see http://localhost:7990/<....>/project.git in the URL instead of the base URL http://git.domain.com/<...>/project.git. 

I would guess this all stems from the same issue, but even through searching all of the answers online, I cannot figure out a solution to this problem!

How do I stop it from referencing http://localhost:7990 even when the base URL is configured?

Also, I am not using SSL and do not plan to at this time.

For reference, this is what my reverse proxy nginx script looks like:

server {
    server_name git.domain.com;
    listen 80;

    location / {
        proxy_pass http://localhost:7990/;
        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;
   
        client_max_body_size 10M;
        proxy_connect_timeout 180s;
        proxy_send_timeout 180s;
        proxy_read_timeout 180s;
    }
}

1 answer

1 accepted

1 vote
Answer accepted
Christian Glockner
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 15, 2020

Hi Michael,

You'll need to add 

server.proxy-port=80
server.proxy-name=git.company.com

to bitbucket.properties and restart Bitbucket Server.

Cheers,

Christian

Premier Support Engineer

Atlassian

Michael_Plautz May 15, 2020

Thank goodness! That was all it took and now it works.

For anyone else looking, my bitbucket.properties file was not in the same location as my bitbucket installation on CentOS 7. The installation is in the /opt/atlassian/bitbucket directory, whereas this properties file is in /var/atlassian/application-data/bitbucket (in the shared directory).

These are instructions I have been unable find online in all my google searches for "Install bitbucket behind nginx reverse proxy," with various combinations of including my operating system and bitbucket server version.

Can you point me to where I should have found these installation steps to correctly configure this installation behind the reverse proxy?

Christian Glockner
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 15, 2020

Hi Michael,

The title of this article is perhaps a bit misleading, because it applies regardless of whether you use SSL or not:

https://confluence.atlassian.com/bitbucketserver/securing-bitbucket-server-behind-nginx-using-ssl-776640112.html

Cheers,

Christian

Premier Support Engineer

Atlassian

Like Michael_Plautz likes this
Michael_Plautz May 15, 2020

Thank you. I now recall even looking at this article, but I was unable to make the leap between using port 443/TCP for SSL and 80/TCP for standard HTTP in the properties file. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.1.1
TAGS
AUG Leaders

Atlassian Community Events