Changing Base URL of Stash doesn't seem to work

I modified the base URL of my Stash instance to http://myserver.mydomain.com/stash, and have nginx redirecting. I also modified the Context path in server.xml to point to "/stash".

I can log in just fine and use Stash using http://myserver.mydomain.com/stash, but I noticed two issues: clicking on the Stash logo in the upper-left corner of the page tries to link to "http://localhost:7990". The other issue is linking to Jira and Confluence; they also believe Stash is at http://localhost:7990. Anyone else encounter this problem? Thanks!

6 answers

Hi Jim,

Have you configured the server.xml to also include the proxy name/port?This is for apache, but the server.xml changes need to happy for nginx as well:

https://confluence.atlassian.com/display/STASH/Integrating+Stash+with+Apache+HTTP+Server

Cheers,

Charles

Yes, Charles - I did. I can log into Stash without problems. I also double-checked the base URL set for Stash, and that is correct as well. It seems the internal Stash application doesn't use the base URL setting, since I've also found that creating new project/repositories also has the same problem.

Hi Jim,

In those instances Stash uses the 'Host' HTTP header which is being sent via your Nginx. Do you have some configuration on the proxy side that would result in that header being sent incorrectly?

Cheers,

Charles

If you get stuck, would it be possible for you to attach your nginx and server.xml files? Or sanitized snippets so we can take a looK?

Charles

The snippet of my nginx config file:

location ^~ /jira {

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_pass http://localhost:8080;

}

location ^~ /confluence {

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_pass http://localhost:8090;

}

location ^~ /stash {

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_pass http://localhost:7990;

}


And my server.xml snippet file from Stash:

<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<!-- Before changing the context path for Stash, please read our documentation:
You will have to update scripts.cfg AND
rename webapps/ROOT directory.
-->
<Context docBase="${catalina.home}/atlassian-stash"
path="/stash"
reloadable="false"
useHttpOnly="true"/>
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
...

Hi Jim,

Thanks for that. I can't see the <Connector> node in your server.xml, so you might already have this (as mentioned in the Apache documentation):

&lt;Connector ... 
    proxyName="myserver.mydomain.com" 
    proxyPort="80" /&gt;

Cheers,

Charles

Hi Jim,

You might also be interested in the following:

http://stackoverflow.com/questions/12847771/configure-nginx-with-proxy-pass

Note the setting of the Host http header:

proxy_set_header Host $host;

I hope that helps.

Charles

Charles,

Thanks - Adding proxy_set_header Host $Host solved the problem. It was perplexing because Jira and Confluence do not require this setting in nginx.

Confirmed that adding:

proxy_set_header Host $host;

Fixed my issue with Stash + nginx.

compressableMimeType="text/html,text/xml,text/plain,text/css,application/json,application/javascript,application/x-javascript"

proxyName="stash......

proxyPort="80" />

Hi guys,

 

I have almost similiar issue Jim was facing but It's with IIS reverse proxy.
I have bitbucket server 5.2 and changed the URL from https://myserver.mydomain.com to https://myserver.abc.mydomain.com.

It's working normally but when I am trying to create a new branch from the Jira cloud page, it redirected to old URL.

Checked:

  1. DNS record
  2. IIS hostname and bindings
  3. Bitbucket proxy URL under bitbucket.properties
  4. Reintergrate the Bitbucket Server and and Jira cloud.

Thanks

It resolved itself, might be it was using the cached and took four-five days to update but not sure where it stored.

Suggest an answer

Log in or Join to answer
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...

709 views 0 4
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot