在一次部署应用的时候,发现系统可以正常登陆,但是登录后,浏览器报错,还是让输入用户名跟密码,说明登陆时发到后端的请求,没有成功,后端是拒绝的,再过一段时间会timeout。
起初以为是反向代理中使用的https开启了客户端验证,nginx默认是不开启的,后来排查到,是因为nginx默认会自动将请求头参数带的下划线去掉,横杠没事儿,最后只需要关闭该选项就行:
underscores_in_headers on;
该参数默认为off,设置为on即可,注意多级代理时,需要将每一级代理,都进行设置。
http {
include mime.types;
underscores_in_headers on;
log_format access_main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
'$http_requestPlatform $http_saleType "$http_XK_Autho" $http_my_token';
access_log logs/access.log access_main;
}
设置完成后,问题就解决了,也算长经验了,项目上线时会遇到各种问题,耐心解决即可。
参考:https://blog.csdn.net/kq1983/article/details/113182842