首頁  >  文章  >  運維  >  nginx中怎麼部署存取vue-cli搭建的項目

nginx中怎麼部署存取vue-cli搭建的項目

王林
王林轉載
2023-05-28 13:04:061021瀏覽

用history模式建置的專案需要藉助後台技術,這裡選用的是nginx反向代理程式來部署專案。具體做法如下:

1、建立後台伺服器 物件

upstream mixVueServer{ 
  server baidu.com;#这里是自己服务器域名 
}

2、建立存取連接埠和反向代理規則

server { 
    listen    8082; 
    server_name localhost; 

    location / { 
      root  E:/mix_vue/dist;#定位到项目的目录 
      #index index.html index.htm; 
    try_files $uri $uri/ /index.html;#根据官网这规则配置 
    } 
  location ~ \.php${ 
    proxy_pass http://mixVueServer;#根据后端语言做反向代理处理跨域问题 
    proxy_set_header  Host  $host; 
    proxy_set_header  X-Real-IP  $remote_addr; 
  } 
   
    error_page  500 502 503 504 /50x.html; 
    location = /50x.html { 
      root  html; 
    } 
  }

以上是nginx中怎麼部署存取vue-cli搭建的項目的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:yisu.com。如有侵權,請聯絡admin@php.cn刪除