各位大佬好,有个问题困扰好几天了,事情是这样的:
nginx和网关部署在一个服务器上,
nginx 反向代理 get请求 参数有特殊字符 400错误
后台业务系统有一个get接口格式为:http://oa.test.com.cn/oa/visitapp/taskList/%7B%22userId%22:%22aaa%22%7D (注:{"userId":"aaa"}转义后),通过postman测试正常返回。
网关配置路由后的uri为:http://10.10.130.47:18444/api/mobile/attendance/oa/visitapp/taskList/%7B%22userId%22:%22aaa%22%7D,通过postman直接调用测试,正常返回。可以排除是网关问题。
现在在这台10.10.130.47服务器(80默认端口)通过nginx代理转发到gateway网关,地址为:
http://10.10.130.47/api/mobile/attendance/oa/visitapp/taskList/%7B%22userId%22:%22aaa%22%7D,通过postman测试,400错误,。经过测试发现问题:url中只要带有{},""或者转义后的%7B、%7D、%22,都会报400错误。
其他形式的get接口是可以访问通过的,类似:http://10.10.130.47/api/mobile/attendance/oa/visitapp/taskList?key=value
事先说明这种接口http://url/{json}的格式的确不规范,但是后台服务改不了。
nginx.conf 配置片段如下:
location /api/mobile {
proxy_pass http://10.10.130.47:18444/api/mobile;
client_max_body_size 200m;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_buffering off;
}
设置 proxy_pass http://10.10.130.47:18444
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass
哥们,你这个问题 解决了么? 我遇到和你一样的问题啊 , 在Nginx端怎么解决 ?怎么写配置啊,麻烦告诉下,谢谢
请问解决了吗?解决方式是什么呀