今天工作中遇到用 localhost 訪問網站能訪問后臺 api,但是用本機IP地址后就拒絕訪問,我懷疑是后臺獲取?Remote Address 然后設置白名單了只能 localhost 訪問。
想用 nginx 更改?Remote Address
server {listen 8058;server_name localhost;location / {proxy_pass http://localhost:8080/; # 后端地址和端口proxy_set_header Host "localhost:8080";proxy_set_header Origin "http://localhost:8080";proxy_set_header Referer "http://localhost:8080";proxy_set_header Connection "keep-alive";proxy_set_header Cookie $http_cookie;}}
經過測試發現后端是用?Referer 這個字段做的白名單,更改這個頭就可以通過驗證了,如果需要別的頭可以按這個方法設置就可以。