Всем доброго времени суток. Такая ситуация, есть веб-сервер на 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]