# 关键代码
resolver 服务器dns(可以多个) valid=5 ipv6=off;
# 关键代码
set $skyneturl "https://aip.baidubce.com";
location /xxxx/baidu/rest/2.0/ocr/v1/business_license {
lua_need_request_body on;
log_escape_non_ascii off;
body_filter_by_lua '
local resp_body = string.sub(ngx.arg[1], 1, 1000)
ngx.ctx.buffered = (ngx.ctx.buffered or "") .. resp_body
if ngx.arg[2] then
ngx.var.resp_body = ngx.ctx.buffered
end
';
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 150;
proxy_send_timeout 150;
#转发地址
# proxy_pass https://aip.baidubce.com/;
# 关键代码
proxy_pass $skyneturl/baidu/rest/2.0/ocr/v1/business_license?$args;
}
请求地址:http://localhost:port/xxxx/baidu/rest/2.0/ocr/v1/business_license?access_token=465465416
注意:resolver 结合set 才好使 不知道为啥