nginx部署前端和后端接口


http {

  #前端部署

  server {

    listen                 8099;  #监听  8099  端口

    server_name     localhost;

    location / {

      root     D:\Mine\Test\2020.6.8\wdq\dist;   #  指向本地 vue  build 的 dist 地址

      index   index.html index.htm;

      try_files $uri $uri/ /index.html;   #对 Vue Router 做匹配

    }

    #后端接口部署:要代理的接口,通过路径匹配

    location /power {    # power 为后端接口的前缀

      proxy_pass http://10.98.164.41:9001;   #此地址为后端接口的地址

      proxy_set_header X-Forwarded-For $remote_addr;

      proxy_set_header Host $host;

      proxy_set_header X-Real-IP $remote_addr;

      proxy_set_header Upgrade $http_upgrade;   #支持websocket

      proxy_set_header Connection "ipgrade";    #支持websocket

    }

  }

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM