Teamcity /login at localhost instead of hostname behind nginx

I am using nginx to proxy my dev rails app back to unicorn. I setup /teamcity to proxy on back to /teamcity.

$ nginx -v
nginx version: nginx/0.7.65



My config...


location ~ /teamcity/ {

     proxy_pass http://localhost:8111;

}



I renamed ~/TeamCity/webapps/ROOT to ~/TeamCity/webapps/teamcity.

$ grep dev .BuildServer/config/*

.BuildServer/config/main-config.xml:<server rootURL="http://dev.product.com/teamcity/">



And this all works fine. Except when I am logged out and I hit a page, it redirects me to http://localhost/teamcity/login.html instead of with the right hostname. I'm sure this is because of the nginx proxy is requesting with the hostname of localhost.

If I hit it by IP address, it works fine. http://10.10.10.10:8111/teamcity/ -> http://10.10.10.10:8111/teamcity/login.html.

Is there a way to force that redirect to take into account the rootURL for the instance?

Thanks!
3 comments
Comment actions Permalink

Turns out I can cheat. Once I figured out the right combo of google words.

location ~ /teamcity/ {

     proxy_pass http://localhost:8111;

     proxy_set_header Host $host;

}

Will pass the right hostname along via the request. This fixes my issue but not the underlying problem that the login redirect ignores the configured rootURL.

0
Comment actions Permalink

Hi Travis.

I cannot reproduce it so far. Is it still actual issue?
What is external address of your Nginx server, and what URL are you redirected after logout?

Thanks

0
Comment actions Permalink

I see it as an issue, but easily addressable by configuration, so maybe not a real problem. It is reproducable.

So I request http://dev.product.com/teamcity. It gets routed to ngnix on port 80. nginx forwards the request to http://localhost:8111/teamcity/. The heads of the HTTP request say the host is localhost (unless you tell nginx to rewrite them, which is my second post). When logging out TeamCity uses the host from the http headers to push you back to login screen. This doesn't work under this configuration.

Does this make sense?

0

Please sign in to leave a comment.