nginx反向代理配置訪問(wèn)后臺(tái),基礎(chǔ)問(wèn)題?
問(wèn)題描述
報(bào)錯(cuò)截圖如下:
XMLHttpRequest cannot load http://localhost:9090/services/user/login. Response to preflight request doesn’t pass access control check: No ’Access-Control-Allow-Origin’ header is present on the requested resource. Origin ’http://localhost:9000’ is therefore not allowed access. The response had HTTP status code 403.
反向代理配置如下:
請(qǐng)問(wèn),配置哪里出了問(wèn)題?
問(wèn)題解答
回答1:是跨域問(wèn)題吧,參見(jiàn)/a/11...
回答2:server_name 用 localhost 就好,不必帶端口,不然 http://localhost:9090/services/ 就轉(zhuǎn)發(fā)到 9000 端口了。配置其他部分應(yīng)該沒(méi)毛病,提一點(diǎn)建議,nginx配置也貼代碼而不是圖片就好了,謝謝。
server { listen 9090; server_name localhost; // 修改這里location /front/ {proxy_pass http://127.0.0.1:9000/; }location /services/ {proxy_pass http://127.0.0.1:8080/services/; }}回答3:
根據(jù)錯(cuò)誤提示,應(yīng)該是你的 Apache 沒(méi)有 services/ 目錄的訪問(wèn)權(quán)限?是不是項(xiàng)目路徑不在 Apache 默認(rèn)路徑下,是的話要做相應(yīng)的配置
回答4:把location /services/ 改成 location /services
相關(guān)文章:
