Changing Base URL of Stash doesn't seem to work

Jim Leary August 26, 2013

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

2 votes
cofarrell
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.
August 26, 2013

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

Jim Leary August 26, 2013

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.

cofarrell
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.
August 26, 2013

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

cofarrell
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.
August 26, 2013

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

Jim Leary August 26, 2013

I also found this link: https://confluence.atlassian.com/display/STASHKB/Moving+Stash+to+a+different+context+path

But it assumes http://localhost:7990/stash ... and that's not what I'm looking for.

Jim Leary August 26, 2013

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 -->
...
cofarrell
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.
August 26, 2013

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

cofarrell
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.
August 26, 2013

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

Jim Leary August 26, 2013

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.

0 votes
Gurpreet Singh July 31, 2017

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

Gurpreet Singh August 2, 2017

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

0 votes
ThiagoBomfim
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 7, 2015
0 votes
Deleted user August 4, 2014

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

proxyName="stash......

proxyPort="80" />

0 votes
Ryan Lobik May 13, 2014

Confirmed that adding:

proxy_set_header Host $host;

Fixed my issue with Stash + nginx.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events