Nginx 直接返回json

Nginx 直接返回json

作者:Bright Xu

location /ip {
    default_type application/json;
    add_header Access-Control-Allow-Credentials true;
    add_header Access-Control-Allow-Origin *;
    add_header Cache-Control public;
    add_header Cache-Control max-age=300;
    return 200 '{"code":$status,"ip":"$remote_addr","User-Agent":"$http_user_agent"}';
}

猜你喜欢

转载自blog.csdn.net/weixin_44129085/article/details/115264767