nginx部署前端靜態代碼解決本地接口調用跨域問題


server {
    listen 90;
    server_name localhost;

    #charset koi8-r;

    #access_log logs/host.access.log main;
    proxy_set_header Host $host:$server_port; //需要加上,解決運行時端口丟失問題
location / {
    root html;
    index index.html index.htm;
}
// 將 藍色的 丟進去 改一下對應的

 

 //js內ajax請求的ip地址  如 localhost:8080/api/      改為   /apis/api   
location /apis {               
      rewrite ^.+apis/?(.*)$ /$1 break;
      include uwsgi_params;
                    proxy_pass http://localhost:8080;  //  需要調用的后台ip地址  
}

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM