Bitbucket: Base URL Mismatch

Ashley Kitson May 23, 2017

I have Bitbucket 4.12.0 running fine without SSL.  I've now put it behind an Nginx reverse proxy and followed the instructions.  Here's my BITBUCKET_HOME/shared/bitbucket.properties server section:

server.port=7990
server.secure=true
server.scheme=https
server.proxy-port=443
server.redirect-port=443
server.proxy-name=my.domain.com
server.context-path=/

server.proxy-name matches that in the admin baseUrl settings.

The nginx config is this:

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

    location / {
        return 301 https://$host$request_uri;
    }
}

server {

    listen 443 ssl;
    server_name my.domain.com;

    ssl on;
    ssl_certificate "/etc/certs/my.domain.com/fullchain.pem";
    ssl_certificate_key "/etc/certs/my.domain.com/privkey.pem";
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
    #ssl_ecdh_curve secp384r1;
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:10m;
    ssl_session_tickets off;
    ssl_stapling on;
    ssl_stapling_verify on;

    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;



      proxy_redirect      http://localhost:7990 https://my.domain.com;
#       proxy_redirect  off;
    }
  }

Setting proxy_redirect off; causes a failure to subit forms on the site (as .  The line that is in does not.

Despite all this, the BitBucket icon at top left still inks to http://localhost:7990  and I get the red banner at the top with the 'You are accessing Bitbucket from a URL that does not match the configured base URL. You may want to change it.' message.

The instructions are slightly confusing, as I was expecting to have to have a server.xml file, but replacing the bitbucket.properties with server.xml meant bitbucket wouldn't even start.

I can see that this sort of question has been asked before, but nothing I've seen so far has helped.

TIA

1 answer

0 votes
Ben Stuart
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 25, 2018

Hey Ashley, It looks like you're using the instructions for Bitbucket 5.0+ after we switched to Spring Boot. For 4.12 you should still be using the server.xml per our instruction here:

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

Give that a try and hopefully it works. :)

rahul_hyundai June 28, 2019

Hello @Ashley Kitson 

Did you get any solution for this, as i am also getting same issue with my bitbucket and ngnix,

what code do i need to right in ngnix.conf file so that it will point to url not to ip address.

server {
listen 8081 ssl;
server_name bitbucket.domain;
ssl_certificate abc.cer;
ssl_certificate_key abc.pkcs8;

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;

ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location / {
proxy_pass http://ipaddress;

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events