nGinX HTTP-Code 200 / 404

Maik Unger lists at ruby-forum.com
Tue Jan 10 10:34:59 UTC 2012


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_set_header                X-Real-IP 
$remote_addr;
                proxy_set_header                X-Forwarded-For 
$proxy_add_x_forwarded_for;
                proxy_set_header                Referer 
$http_referer;
                proxy_set_header                Accept-Language 
$http_accept_language;

                client_max_body_size            64m;
                client_body_buffer_size         128k;

                proxy_connect_timeout           90;
                proxy_send_timeout              90;
                proxy_read_timeout              90;

                proxy_buffer_size               4k;
                proxy_buffers                   4 32k;
                proxy_busy_buffers_size         64k;
                proxy_temp_file_write_size      64k;

                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.

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/.



More information about the nginx mailing list