bitbucket behind apache ssl reverse proxy not allowing branch creation

Iain Donaldson January 8, 2017

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

1 accepted

0 votes
Answer accepted
Iain Donaldson January 9, 2017

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!

0 votes
Daniel Wester
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 8, 2017

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

Iain Donaldson January 8, 2017

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.

 

0 votes
Timothy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 8, 2017

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

Iain Donaldson January 8, 2017

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events