ПРОЕКТЫ 


  АРХИВ 


Apache-Talk @lexa.ru 

Inet-Admins @info.east.ru 

Filmscanners @halftone.co.uk 

Security-alerts @yandex-team.ru 

nginx-ru @sysoev.ru 


  СТАТЬИ 


  ПЕРСОНАЛЬНОЕ 


  ПРОГРАММЫ 



ПИШИТЕ
ПИСЬМА












     АРХИВ :: nginx-ru
Nginx-ru mailing list archive (nginx-ru@sysoev.ru)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

nginx 400 bad request при разных ip в запросе


  • To: nginx-ru@xxxxxxxxx
  • Subject: nginx 400 bad request при разных ip в запросе
  • From: "daevy" <nginx-forum@xxxxxxxx>
  • Date: Tue, 12 Oct 2010 04:25:48 -0400
  • Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mickey.jlkhosting.com; s=x; h=Sender:From:Message-ID:Content-Transfer-Encoding:Content-Type:Subject:To:Date; bh=aFO/l6r2158TgFSpbjif4RIv9v1Lon0Nd0md/kiyMv0=; b=bb31AwWonm72XrdUvIOz4eWciDwtNI9Hx6+RnbTtGQmbHO0fvWndOtcWfEiwvcZTFwt1b7/whu0HEd+y1DX1hjIkIENnmZ59uUEnx5qVoG+1FofiYBT7inx3X/tjW6de;

Всем доброго времени суток. Такая
ситуация, есть веб-сервер на nginx в
качестве фронтэнда, отдающий запросы
ruby-приложению. Сервер слушает два
адреса, один - 192.168.40.55; второй - 212.49.52.16.
так вот сервер реагирует на запрос в
зависимости от того на какой ip он
пришел. если на внутренний, то
страничка отдается. если на внешний -
nginx отдает 400 Bad request. Кто знает в чем
может быть проблема подскажите. Ниже
конфигурация 
nginx
[code]
user nginx devel;
worker_processes 1;
worker_rlimit_nofile 10240;

error_log /var/log/nginx/error_log info;

events {
        worker_connections  8192;
        use epoll;
}

http {
        include         /etc/nginx/mime.types;
        default_type    application/octet-stream;

        passenger_root /usr/libexec/passenger;
        passenger_ruby /usr/bin/ruby;
        passenger_log_level 1;

        log_format main
                '$remote_addr - $remote_user [$time_local] '
                '"$request" $status $bytes_sent '
                '"$http_referer" "$http_user_agent" '
                '"$gzip_ratio"';
                                                                        
      
        client_header_timeout   10m;
        client_body_timeout     10m;
        send_timeout            10m;

        connection_pool_size            256;
        client_header_buffer_size       1k;
        large_client_header_buffers     4 8k;
        request_pool_size               4k;
        server_names_hash_bucket_size   33;

        proxy_read_timeout 120;
        proxy_connect_timeout 120;
        client_max_body_size            50m;

        gzip                    on;
        gzip_min_length         1100;
        gzip_buffers            4 8k;
        gzip_comp_level         9;
        gzip_http_version       1.0;
        gzip_proxied            any;
        gzip_types              text/plain text/css
application/x-javascript text/xml application/xml application/xml+rss
text/javascript;

        output_buffers  1 32k;
        postpone_output 1460;

        sendfile        on;
        tcp_nopush      on;
        tcp_nodelay     on;

        keepalive_timeout       75 20;
        ignore_invalid_headers  on;
        index index.html;
        include vhosts/*.conf;
}
[/code]

и файл проблемного сайта

[code]
server {
        listen          0.0.0.0:22080;
        server_name     .devtest.devel.example.ru;

        passenger_enabled       on;
        rails_env               production;
        rails_spawn_method      smart;

        root            /home/dev/example/public;
        error_log       /var/log/nginx/example.ru_error_log info;
}

upstream nginx_passenger_devtest {
        server localhost:22080;
}

server {
        listen          0.0.0.0;
        server_name     .devtest.devel.example.ru;

        passenger_enabled       off;

        access_log      /var/log/nginx/example.ru_access_log main;
        error_log       /var/log/nginx/example.ru_error_log info;

        root /home/dev/example/public;

        location = / {
                if ($host ~* "^([^.]+)\.devtest\.devel\.example\.ru$" )
{
                        set  $region  $1;
                }
                if (-f $document_root/cache/root/index_${region}_.html)
{
                        rewrite / /cache/root/index_${region}_.html
break;
                        add_header Cache-Control "no-store, no-cache,
must-revalidate, post-check=0, pre-check=0";
                        add_header Pragma "no-cache";
                        charset utf-8;
                }

                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;


                if (!-f $document_root/cache/index_${region}_.html) {
                        proxy_pass  http://nginx_passenger_devtest;
                }
        }

        if (-f $document_root/system/maintenance.html) {
                rewrite ^(.*)$ /system/maintenance.html break;
        }

        location ~ ^\/firms\/.*\/stats\/add_hit\.(js|gif)$ {
                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_pass http://nginx_passenger_devtest;
        }

        location ~ ^/$ {
                if (-f /index.html) {
                        rewrite ^(.*)$ /index.html last;
                }

                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_pass http://nginx_passenger_devtest;
        }

        location ~*
^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov)$
{
                expires      1d;
        }

        # resend everything else to backend
        location / {
                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_pass  http://nginx_passenger_devtest;
        }

        location /robots.txt {
                root /home/dev/example;
        }
}

[/code]

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?21,139624,139624#msg-139624


_______________________________________________
nginx-ru mailing list
nginx-ru@xxxxxxxxx
http://nginx.org/mailman/listinfo/nginx-ru


 




Copyright © Lexa Software, 1996-2009.