Welcome! Log In Create A New Profile

Advanced

Re: nGinX HTTP-Code 200 / 404

Maxim Dounin
January 10, 2012 08:06AM
Hello!

On Tue, Jan 10, 2012 at 11:34:59AM +0100, Maik Unger wrote:

> Hello,
>
> Out Config-File is:
>
> server {
> listen xxx.xxx.xxx.xxx:80;
> server_name domain.foobar.org;
> access_log
> /var/www/html/domain.foobar.org/logs/nginx_domain.foobar.org_access.log
> main;
>
> location / {
> proxy_pass
> http://xxx.xxx.xxx.xxx:8080;
> proxy_redirect off;
>
> proxy_set_header Host $host;

[...]

> proxy_cache STATIC;
> proxy_cache_valid 200 30m;
> proxy_cache_valid any 1m;
> proxy_cache_use_stale error timeout
> invalid_header updating http_500 http_502 http_503 http_504;
> }
> }
>
> As you can see, we have already set the parameter proxy_set_header. The
> problem occurs randomly, not all the time. When the problem occurs, we
> got the apache server startpage with the servers hostname.

Which server's hostname? The one matching "domain.foobar.org", or
something else?

Two possible causes I would consider are:

1. Cache is poisoned by unrelated requests. This may happen if
you use the same proxy_cache in other server{} blocks, or if the
server{} block in question may be used for other hostnames as
well (i.e. it's default one).

2. Something wrong happens on backend and it returns wrong
response(s) sometimes. This may happen for a second or even
a single request, but as you have cache configured - the response is
cached for a relatively long time and hence you see it. E.g. this
may be caused by some periodic backend's config regeneration.

Maxim Dounin



>
> Maxim Dounin wrote in post #1040185:
> > Hello!
> >
> > On Tue, Jan 10, 2012 at 09:42:45AM +0100, Maik Unger wrote:
> >
> >> Hy,
> >>
> >> We have that problem, that a site is not reachable throught nginx with
> >> the domain name (for example www.foobar.org), even the websites are
> >> reachable without nginx directly to apache.
> >>
> >> This problem is not time specific, so that we have no solution at this
> >> moment.
> >>
> >> What is the problem here?
> >
> > Most likely you are using wrong config.
> >
> > By default nginx will use hostname as specified in proxy_pass
> > directive, i.e.
> >
> > proxy_pass http://127.0.0.1:8080;
> >
> > will generate request with Host header set to "127.0.0.1:8080",
> > not to "www.foobar.org". Your backend server won't recognize it
> > if it's configured to serve many virtual hosts, and
> > "www.foobar.org" is just one of them.
> >
> > To preserve the hostname from the original request (as sent to
> > nginx server), use
> >
> > proxy_pass http://127.0.0.1:8080;
> > proxy_set_header Host $host;
> >
> > Maxim Dounin
>
> --
> Posted via http://www.ruby-forum.com/.
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

nGinX HTTP-Code 200 / 404

Maik Unger January 10, 2012 03:44AM

Re: nGinX HTTP-Code 200 / 404

Maxim Dounin January 10, 2012 05:26AM

Re: nGinX HTTP-Code 200 / 404

Maik Unger January 10, 2012 05:36AM

Re: nGinX HTTP-Code 200 / 404

Maxim Dounin January 10, 2012 08:06AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 207
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready