bitbucket behind apache ssl reverse proxy not allowing branch creation

I've just installed Bitbucket on my local server and configured it behind an apache reverse proxy. Bitbucket is working but the branch creation does not work. If I access directly using the :7990 port the branch creation works so it's definitely linked to the reverse proxy configuration.

In my server.xml I have:

<Connector port="7990" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   useBodyEncodingForURI="true"
                   compression="off"            compressableMimeType="text/html,text/xml,text/plain,text/css,application/json,application/javascript,application/x-javascript" />
                   secure="true"
                   scheme="https"
                   proxyName="bitbucket.mydomain.com"
                   proxyPort="443" />

but in my server config requires me to enter the baseUrl as 'http://bitbucket.mydomain.com' rather than 'https://bitbucket.mydomain.com' which otherwise it gives me the banner saying my base url config is not correct. This change to http and compression is turned off was recommended in other forum answers.

Anyone any ideas? There must be something I've missed that's causing this. I've not tested pull requests etc so expect that it may not be simply branches that are not working correctly.

 

3 answers

0 vote
Timothy Chin Community Champion Jan 08, 2017

https should be the right baseUrl. Also check if you have forced redirect of port 80 to 443 in your Apache configuration.

The issue is that if I put https:// in the baseUrl I get the warning that it's not the right URL when accessing it via HTTPS. I also have a redirect on the non secure URL (port 80) as follows:

Redirect / https://bitbucket.mydomain.com/

So all should be fine.

0 vote

There's more than likely an issue with your apache configuration. Can you paste in the configuration that you have?

The apache config on SSL is as follows:

ServerName bitbucket.mydomain.com
ErrorLog /var/log/virtualmin/bitbucket.mydomain.com_error_log
CustomLog /var/log/virtualmin/bitbucket.mydomain.com_access_log combined
SSLEngine on
SSLCertificateFile /home/bitbucket/ssl.cert
SSLCertificateKeyFile /home/bitbucket/ssl.key
SSLCACertificateFile /home/bitbucket/ssl.ca
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
ProxyPreserveHost On
ProxyPass / http://localhost:7990/
ProxyPassReverse / http://localhost:7990/

And on port 80 is:

ServerName bitbucket.mydomain.com
DocumentRoot /home/bitbucket/public_html
ErrorLog /var/log/virtualmin/bitbucket.mydomain.com_error_log
CustomLog /var/log/virtualmin/bitbucket.mydomain.com_access_log combined
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/bitbucket/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
Redirect / https://bitbucket.mydomain.com/

What I do see is when the branch create is clicked that there is a POST request to the server that is rejected with a 403 response:

[09/Jan/2017:08:40:39 +0000] "POST /rest/branch-utils/latest/projects/COM/repos/com/branches HTTP/1.1" 403 488 "https://bitbucket.mydomain.com/plugins/servlet/create-branch" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/602.3.12 (KHTML, like Gecko) Version/10.0.2 Safari/602.3.12"

so yes looks like it's something in the config between Apache and bitbucket. Any help appreciated.

 

Fixed this - the issue was the Connector element in the server.xml - a stray closing angle bracket was above the proxy settings '/>'

Can't believe I missed that!

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,758 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you