ngx_http_userid模块在运行Docker容器时没有生成$ uid_got

时间:2016-10-13 14:47:03

标签: nginx docker

我正在使用以下命令运行基于我的图像francotestori / kd-nginx的nginx docker容器:

sudo docker run --name kd-nginx -v /tmp/log/nginx/:/var/log/nginx/ -v /var/www/:/var/www/ -p 80:80 -d francotestori/kd-nginx

共享的www目录是因为我需要提供静态文件

日志目录是因为我想访问我的不同日志样本

问题在于,由于某种原因,ngx_http_userid模块无法识别用户请求,并且永远不会分配令牌。因此,虽然我的日志调用$ uid_got标记变量,但变量最终为空。

这是我的nginx.conf文件:

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

#user nginx;
user www-data;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
    worker_connections 1024;
}

http {

    geoip_country  /usr/share/GeoIP/GeoIP.dat;       # the country IP database
    geoip_city     /usr/share/GeoIP/GeoLiteCity.dat; # the city IP database

    userid  on;
    userid_name uid;
    userid_domain static1.keyneticdigital.com;
    userid_path /;
    userid_expires  1h;
    userid_p3p  'policyref="/w3c/p3p.xml", CP="CUR ADM OUR NOR STA NID"';

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

    log_format tracking '$time_iso8601 :-: $remote_addr :-: $request :-: $status :-: $uid_got :-: $http_x_forwarded_for :-: $http_referer :-: $http_user_agent :-: $geoip_country_code :-: $geoip_region :-: $geoip_city :-: $geoip_latitude :-: $geoip_longitude :-: $query_string';


    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

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

        # Load modular configuration files from the /etc/nginx/conf.d directory.
        # See http://nginx.org/en/docs/ngx_core_module.html#include
        # for more information.
        include /etc/nginx/conf.d/*.conf;

        server {
            listen       80 default_server;
            listen       [::]:80 default_server;
            server_name  *.kdtrck.com;
            root         /usr/share/nginx/html;

            # Load configuration files for the default server block.
            include /etc/nginx/default.d/*.conf;

            location / {
            }

            location /c/ {
                access_log /var/log/nginx/tracking.log tracking;
                root /var/www;
                add_header Cache-Control no-cache;
            }

            location = /trk.gif {
                empty_gif;
                access_log /var/log/nginx/conversion.log tracking;
                expires epoch;
            }

            error_page 404 /404.html;
                location = /40x.html {
            }

            error_page 500 502 503 504 /50x.html;
                location = /50x.html {
            }
        }
    }

此外,我给你留下了一些输出日志:

2016-10-13T13:30:23+00:00 :-: 190.16.190.118 :-: GET /c/c_4.gif HTTP/1.1 :-: 200 :-: - :-: - :-: - :-: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.89 Safari/537.36 :-: AR :-: 07 :-: Buenos Aires :-: -34.6033 :-: -58.3816 :-: -
2016-10-13T13:30:27+00:00 :-: 190.16.190.118 :-: GET /c/c_4.gif HTTP/1.1 :-: 200 :-: - :-: - :-: - :-: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.89 Safari/537.36 :-: AR :-: 07 :-: Buenos Aires :-: -34.6033 :-: -58.3816 :-: -
2016-10-13T13:30:34+00:00 :-: 190.16.190.118 :-: GET /c/c_4.gif HTTP/1.1 :-: 304 :-: - :-: - :-: - :-: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.89 Safari/537.36 :-: AR :-: 07 :-: Buenos Aires :-: -34.6033 :-: -58.3816 :-: -
2016-10-13T14:12:43+00:00 :-: 190.16.190.118 :-: GET /c/c_4.gif HTTP/1.1 :-: 200 :-: - :-: - :-: - :-: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.89 Safari/537.36 :-: AR :-: 07 :-: Buenos Aires :-: -34.6033 :-: -58.3816 :-: -
2016-10-13T14:12:44+00:00 :-: 190.16.190.118 :-: GET /c/c_4.gif HTTP/1.1 :-: 200 :-: - :-: - :-: - :-: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.89 Safari/537.36 :-: AR :-: 07 :-: Buenos Aires :-: -34.6033 :-: -58.3816 :-: -

任何人都知道这种问题的解决方法或nginx如何分配uid?有没有可能丢失的文件?

1 个答案:

答案 0 :(得分:1)

没关系我从不同的域访问我的nginx实例