Nginx $ http_cookie变量得到空值

时间:2016-09-30 02:15:47

标签: http cookies nginx

我想通过"用户ID获取cookie值"在我使用nginx的时候在nginx.conf中,但是,如果有人告诉我为什么,我有时会得到$ http_cookie的空值?

我的nginx.conf就像("用户ID在"配置在" vhost / * .conf"):

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$uid" ';

    server {
        listen 80;
        userid on; 
        userid_name cooid;
        userid_domain xxx.com;
        userid_path /;
        userid_expires 1d;
        server_name yyy.xxx.com;
        set $uid "-";
        if ( $http_cookie ~* "cooid=(\S+)(;.*|$)"){
            set $uid $1; 
        }


        access_log /data/wwwlogs/nginx_logs/yyy.xxx.com.log main;
        index index.html index.htm index.php;
        include /usr/local/tengine/conf/rewrite/none.conf;
        root /data/wwwroot/yyy.xxx.com;

        location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv)$ {
            valid_referers none blocked *.jin10.com analyze.jin10.com;
            if ($invalid_referer) {
                #rewrite ^/ http://www.linuxeye.com/403.html;
                return 403;
            }
        }
        location ~ [^/]\.php(/|$) {
            #fastcgi_pass remote_php_ip:9000;
            fastcgi_pass unix:/dev/shm/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
        }
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
            expires 30d;
            access_log off;
        }
        location ~ .*\.(js|css)?$ {
            expires 7d;
            access_log off;
        }
    }

0 个答案:

没有答案