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

This widget could not be displayed.

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.

This widget could not be displayed.
This widget could not be displayed.

Confirmed that adding:

proxy_set_header Host $host;

Fixed my issue with Stash + nginx.

This widget could not be displayed.

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

proxyName="stash......

proxyPort="80" />

This widget could not be displayed.
This widget could not be displayed.

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 Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 10, 2018 in Bitbucket

What is your #1 piece of advice to new users getting started using Bitbucket?

Hello Community! My name is Claire Maynard, and I’m a Product Marketing Manager on the Bitbucket team. I’m interested in hearing what advice or tips you have for new users getting started on ...

258 views 14 2
Join discussion

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