记录下 logformat

user www-data;
worker_processes  1;
pid        logs/nginx.pid;
error_log /opt/error.log;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    server_tokens off;
    default_type  application/octet-stream;
    log_format  main  '$msec "remote:$remote_addr x-connect:$http_x_connecting_ip - $host $remote_user [$time_local] "$request" '
                               '$status $body_bytes_sent "$http_referer" "$http_cookie" '
                               '"$http_user_agent" xff:"$http_x_forwarded_for" '
                                '"$upstream_addr" "$upstream_response_time" "$upstream_status"'
                                '"$ssl_protocol" "$ssl_cipher" origin:"$http_origin"';
     log_format log_json '{'
                '"msec": "$msec", '
                '"@timestamp": "$time_iso8601", '
                '"request_time": "$request_time", '
                '"porto_version": "$server_protocol", '
                '"remote_addr": "$remote_addr", '
                '"x_forwarded_for": "$http_x_forwarded_for", '
                '"x_connecting_ip": "$http_x_connecting_ip", '
                '"Host": "$host", '
                '"path": "$request_uri", '
                '"method": "$request_method", '
                '"referer": "$http_referer", '
                '"status": $status, '
                '"body_bytes_sent": $body_bytes_sent, '
                '"UA": "$http_user_agent", '
                '"cookie": "$http_cookie", '
                '"up_addr": "$upstream_addr", '
                '"up_host": "$upstream_http_host", '
                '"up_resp_time": "$upstream_response_time", '
                '"up_status": "$upstream_status", '
                '"request_time": "$request_time", '
                '"origin": "$http_origin", '
                '"ssl_proto": "$ssl_protocol", '
                '"ssl_cipher": "$ssl_cipher" ,'
                '"cookie:": "$http_cookie"'
                 '}';



    #include conf.d/*.conf;
    sendfile        on;
    keepalive_timeout  65;

#    add_header Access-Control-Allow-Origin *;
#    add_header Access-Control-Allow-Headers X-Requested-With,Content-Type,If-Modified-Since;
#    add_header Access-Control-Allow-Methods GET,POST,OPTIONS;

    #proxy_set_header X-From 'askjdfhkajshgfkasdhf';



    gzip  on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types text/plain application/x-javascript text/css application/xml;
    gzip_vary on;
    gzip_disable msie6;
    include conf.d/*.conf;
    server {
        listen       65534;
        server_name  ************;
        location / {
             return 521;
#            root   html;
#            index  index.html index.htm;
        }

   }
}
Proudly powered by WordPress | Theme: Code Blog by Crimson Themes.