# Name of upstream is returned to a client and not resolved to a server

**URL:** <https://www.ruby-forum.com/t/name-of-upstream-is-returned-to-a-client-and-not-resolved-to-a-server/222997>\
**Category:** NGINX\
**Created:** [September 18, 2012, 11:30am UTC](https://www.ruby-forum.com/t/name-of-upstream-is-returned-to-a-client-and-not-resolved-to-a-server/222997 "2012-09-18T11:30:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [September 18, 2012, 11:30am UTC](https://www.ruby-forum.com/t/name-of-upstream-is-returned-to-a-client-and-not-resolved-to-a-server/222997/1 "2012-09-18T11:30:16Z")

</div>

Hello everybody,

I’d like to setup nginx as a softwareloadbalancer, balancing incoming  
requests to different tomcats.

In order to achiev my goal, i defined some upstreams like this:

upstream myupstream {  
server 192.168.x.y:8080 weight=1 max\_fails=10 fail\_timeout=60s;  
server 192.168.x.z:8080 weight=1 max\_fails=10 fail\_timeout=60s;  
}

Surfing to [mysubdomain.mysite.com](http://mysubdomain.mysite.com) is handled by this location block in a  
serverblock with the servername [mysubdomain.mysite.com](http://mysubdomain.mysite.com):

location = / {  
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://myupstream/home/index?layoutTheme=mysubdomain\_theme](http://myupstream/home/index?layoutTheme=mysubdomain_theme);  
}

This still works fine. But when i click a link on that webpage, leading  
to the startpage of the website (the link is something like  
[http://mysubdomain.mysite.com/home/index?layoutTheme=mysubdomain\_theme](http://mysubdomain.mysite.com/home/index?layoutTheme=mysubdomain_theme))  
I get an error message.  
The request, produced by that link should be handled by this location  
block in the same server block:  
location / {  
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://myupstream](http://myupstream);  
}  
A Chromium based browser shows “Error 105 (net::ERR\_NAME\_NOT\_RESOLVED):”  
and Firefox tells me, that the server [www.myupstream.com](http://www.myupstream.com) could not be  
found.  
Can anyone help me locate the mistake I made in my configuration?  
I’m using Ubuntu server 12.04.1 and nginx 1.2.3 out of the nginx  
repository.

Have a nice Day  
T.Hipp

---

<div class="post-metadata">

**Author:** ![Tobias\_Hipp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5f8ce5/32.png) [@Tobias\_Hipp](https://www.ruby-forum.com/u/Tobias_Hipp)\
**Post date:** [September 18, 2012, 10:10pm UTC](https://www.ruby-forum.com/t/name-of-upstream-is-returned-to-a-client-and-not-resolved-to-a-server/222997/2 "2012-09-18T22:10:44Z")

</div>

On Tue, Sep 18, 2012 at 11:29:18AM +0200, Tobias Hipp wrote:

Hi there,

> [http://mysubdomain.mysite.com/home/index?layoutTheme=mysubdomain\_theme](http://mysubdomain.mysite.com/home/index?layoutTheme=mysubdomain_theme))  
> I get an error message.

> A Chromium based browser shows “Error 105 (net::ERR\_NAME\_NOT\_RESOLVED):”  
> and Firefox tells me, that the server [www.myupstream.com](http://www.myupstream.com) could not be  
> found.

That sounds like the links are referring to [http://myupstream](http://myupstream), and the  
two browsers have different error reporting/correcting behaviours.

If you view the source returned from the original  
[http://mysubdomain.mysite.com/](http://mysubdomain.mysite.com/) request, you may see that there.

> Can anyone help me locate the mistake I made in my configuration?

I guess that the tomcats are building “full” links instead of relative  
ones. Or else they are issuing http redirects, and are not using the  
server name you want them to.

Possibly adding

proxy\_set\_header Host $host;

or any variation that uses the appropriate “[mysubdomain.mysite.com](http://mysubdomain.mysite.com)”  
into the two location{}s will cause the tomcats to build full links  
using the public hostname.

If you look at the output of “curl -i” or each request, you might see  
exactly what is going on.

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
