Возможно ли использовать nginx как туннель с кешированием статики и websockets

tao nginx-forum at nginx.us
Wed Jul 3 09:45:24 UTC 2013


в браузере-клиенте (chrome) прописан ip http proxy (nginx) 
на домене club по 3000 порту висит socket.io с поддержкой xhr-pooling и
websockets и nginx для отдачи статики по 80 порту
все хорошо и отлично кешируется c 80 порта, xhr-pooling  тоже работает
отлично

Но как только переключаюсь на websockets  , получаю в логи
==
[ 03/Jul/2013:11:50:17 +0400 ] -  "CONNECT club:3000 HTTP/1.1" "400"
"rt:0.018" "urt:-" "cache: -" 



==== CONFIG
map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
}

upstream club_80        {    server club:80;}
upstream club_3000      {    server club:3000;}

server {

    listen 8090;
    server_name _;
    access_log /var/log/nginx/proxy.8090.access.log common;
    error_log  /var/log/nginx/proxy.8090.error.log;

    source_charset utf-8;
    charset        utf-8;

    recursive_error_pages on;

    #upstream mapping
    set $xport 80;
    if ($http_host ~ ":(\d+)") { set $xport $1; }
    set $upstr "club_${xport}";


    error_page 417 = @cached;
    error_page 418 = @nocached;
    
    proxy_http_version 1.1;
    proxy_set_header        Upgrade         $http_upgrade;
    proxy_set_header        Connection      $connection_upgrade;

    proxy_buffering off;
    
    location / {

        return 417;
    }
   location /socket.io {
        
        return 418;
    }
    
    location ~ /(ru|en/)?index.html {

        return 418;
    }
            
    #for index/socket.io
    location @nocached {
        proxy_read_timeout 86400;
        proxy_cache     off;
        proxy_pass      http://$upstr;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header              Cache-Control  
"no-cache,no-store,must-revalidate";
        expires -1;
    }
        
    #for static
    location @cached {
    
        proxy_cache_methods GET;
        proxy_cache_valid 200 5d;
        proxy_cache clubcache;
        proxy_pass      http://$upstr;
        proxy_set_header        Host            $host:$proxy_port;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_cache_bypass      $cookie_nocache $arg_nocache$arg_comment;
        proxy_cache_bypass      $http_pragma    $http_authorization;

        proxy_ignore_headers    X-Accel-Expires Expires Cache-Control
Set-Cookie;

        add_header Cache-Control "no-cache,no-store,must-revalidate";
        expires -1;

    }
}
================= END

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



Подробная информация о списке рассылки nginx-ru