Nginx 拦截打点与输出配置

server
    {
        listen 80;
        #listen [::]:80;
        server_name dot.test.com;
        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }

                location ~ ^/api/reportLocation 
        {
            default_type    application/json;
            access_log /alidata/log/nginx/xiaode_dot/xiaode_reportLocation.log dot;
            return 200 '{"code":200,"msg":"success"}';
        }

        location ~^/dot/
         {
            default_type text/html;
            access_log /alidata/log/nginx/dot.test.com.log;
            return 200 'su';
         }
               location /
         {
            default_type text/html;
            access_log off;
            return 404 'fail';
         }

        access_log  off;
        error_log /dev/null crit;
    }

NGINX 输出配置说明:

# 直接返回文本:

    location / {
        default_type    text/plain;
        return 502 "服务正在升级,请稍后再试……";
}

# 也可以使用html标签格式:

    location / {
        default_type    text/html;
        return 502 "服务正在升级,请稍后再试……";
    }

# 也可以直接返回json文本:

    location / {
        default_type    application/json;
        return 502 '{"status":502,"msg":"服务正在升级,请稍后再试……"}';
    }

# 返回变量值
    location ~ \.php$ {
        default_type    text/plain;
        return 502 "$document_root$fastcgi_script_name";
    }