鍍金池/ 問(wèn)答/Linux  HTML/ nginx反向代理解決跨域的配置問(wèn)題

nginx反向代理解決跨域的配置問(wèn)題

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        
       
        proxy_pass http://localhost:8080;
        
    }
    
    location /apis {
        
        rewrite /apis / break;
        proxy_pass http://mooc.com;
    }
}

vue項(xiàng)目運(yùn)行在端口8080 我如果直接listen 8080就會(huì)沖突,所以我把80端口轉(zhuǎn)到8080,并把/apis轉(zhuǎn)到真實(shí)接口地址。這樣接口讀取是正常的,但是非常非常緩慢,大概幾分鐘頁(yè)面才會(huì)顯示出來(lái),直接訪問(wèn)8080是秒開(kāi)的,這是為什么呢?我的配置文件有問(wèn)題嗎

回答
編輯回答
心上人

你把http://localhost:8080改成http://127.0.0.1:8080試試

2017年7月13日 04:10