最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue項目nginx二級域名配置方式

 更新時間:2023年06月30日 10:24:35   作者:陳小成  
這篇文章主要介紹了vue項目nginx二級域名配置方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

vue項目nginx二級域名配置

1、將vue項目路由的加入base配置如下圖所示,打包備用

在這里插入圖片描述

2、配置nginx,下圖所示

在這里插入圖片描述

3、在步驟2中的nginx的根目錄下面html文件夾下面新增data文件夾,在data下面新建vue和test文件夾,將步驟1打包的文件放到vue文件夾和test文件夾,訪問本地http://localhost/test/和http://localhost/vue/

在這里插入圖片描述

在這里插入圖片描述

nginx多個vue項目使用獨立二級域名部署

因為項目前后端分離部署,多個項目前端使用同一個nginx發(fā)布,每個項目對應不同的二級域名

  • dsp項目  : dsp.xxxx.com
  • bi項目:bi.xxxx.com

1. 在vue.config.js文件下找到publicPath配置,添加如下配置(vuecli2就是config文件夾下的assetsPublicPath配置)

publicPath: process.env.NODE_ENV === "production" ? "/bi/" : "/bi/",

2.修改項目router的base

export default new Router({
? mode: 'history', // 去掉url中的#
? base: '/bi/',
? scrollBehavior: () => ({ y: 0 }),
? routes: constantRoutes
})

3.修改.env.production

##這個地方改成每個項目不一樣就行了
VUE_APP_BASE_API = '/prod'

4.然后將項目打包

將打包好的文件放到指定目錄下

5.配置nginx

首先修改nginx.conf

# For more information on configuration, see:
# ? * Official English Documentation: http://nginx.org/en/docs/
# ? * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
? ? worker_connections 1024;
}
http {
? ? log_format ?main ?'$remote_addr - $remote_user [$time_local] "$request" '
? ? ? ? ? ? ? ? ? ? ? '$status $body_bytes_sent "$http_referer" '
? ? ? ? ? ? ? ? ? ? ? '"$http_user_agent" "$http_x_forwarded_for"';
? ? access_log ?/var/log/nginx/access.log ?main;
? ? sendfile ? ? ? ? ? ?on;
? ? tcp_nopush ? ? ? ? ?on;
? ? tcp_nodelay ? ? ? ? on;
? ? keepalive_timeout ? 65;
? ? types_hash_max_size 2048;
? ? include ? ? ? ? ? ? /etc/nginx/mime.types;
? ? default_type ? ? ? ?application/octet-stream;
? ? # Load modular configuration files from the /etc/nginx/conf.d directory.
? ? # See http://nginx.org/en/docs/ngx_core_module.html#include
? ? # for more information.
? ? include /etc/nginx/conf.d/*.conf;
? ? #這個地方是我自己建了一個目錄,兩個項目分別在這個目錄下建自己的配置文件
? ? include /etc/nginx/custom/*.conf;
? ? server {
? ? ? ? listen ? ? ? 80 default_server;
? ? ? ? listen ? ? ? [::]:80 default_server;
? ? ? ? server_name ?dsp.xxxx.com;
? ? ? ? root ? ? ? ? /usr/share/nginx/html;
? ? ? ? # Load configuration files for the default server block.
? ? ? ? include /etc/nginx/default.d/*.conf;
?? ?location / {
? ? ? ? }
? ? ? ? error_page 404 /404.html;
? ? ? ? ? ? location = /40x.html {
? ? ? ? }
? ? ? ? error_page 500 502 503 504 /50x.html;
? ? ? ? ? ? location = /50x.html {
? ? ? ? }
? ? }
# Settings for a TLS enabled server.
#
# ? ?server {
# ? ? ? ?listen ? ? ? 443 ssl http2 default_server;
# ? ? ? ?listen ? ? ? [::]:443 ssl http2 default_server;
# ? ? ? ?server_name ?_;
# ? ? ? ?root ? ? ? ? /usr/share/nginx/html;
#
# ? ? ? ?ssl_certificate "/etc/pki/nginx/server.crt";
# ? ? ? ?ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ? ? ? ?ssl_session_cache shared:SSL:1m;
# ? ? ? ?ssl_session_timeout ?10m;
# ? ? ? ?ssl_ciphers HIGH:!aNULL:!MD5;
# ? ? ? ?ssl_prefer_server_ciphers on;
#
# ? ? ? ?# Load configuration files for the default server block.
# ? ? ? ?include /etc/nginx/default.d/*.conf;
#
# ? ? ? ?location / {
# ? ? ? ?}
#
# ? ? ? ?error_page 404 /404.html;
# ? ? ? ? ? ?location = /40x.html {
# ? ? ? ?}
#
# ? ? ? ?error_page 500 502 503 504 /50x.html;
# ? ? ? ? ? ?location = /50x.html {
# ? ? ? ?}
# ? ?}
}

dsp.conf

? ? server {
? ? ? ? listen ? ? ? 80;
? ? ? ? server_name ?dsp.xxxx.com;
?? ??? ?location / {
?? ??? ??? ?try_files $uri $uri/ /index.html;
? ? ? ? ? ? #dsp項目目錄
?? ??? ??? ?root ? /soft/dpf/web;
? ? ? ? ? ? index ?index.html index.htm;
? ? ? ? }
?? ??? ?#prod-api是代理的路徑
?? ??? ?location /prod-api/{
?? ??? ??? ?proxy_set_header Host $http_host;
?? ??? ??? ?proxy_set_header X-Real-IP $remote_addr;
?? ??? ??? ?proxy_set_header REMOTE-HOST $remote_addr;
?? ??? ??? ?proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
? ? ? ? ? ? ##后端服務的地址
?? ??? ??? ?proxy_pass http://localhost:20001/;
?? ??? ?}
? ? ? ? error_page ? 500 502 503 504 ?/50x.html;
? ? ? ? location = /50x.html {
? ? ? ? ? ? root ? html;
? ? ? ? }
? ? }

bi.conf

? ? server {
? ? ? ? listen ? ? ? 80;
? ? ? ? server_name ?bi.xxxx.com;
? ? ? ? root /soft/bi/ui;
?? ?location /bi/ {
?? ? ? ?try_files $uri $uri/ /index.html;
? ? ? ? }
?? ?location /prod/{
?? ??? ?proxy_set_header Host $http_host;
?? ??? ?proxy_set_header X-Real-IP $remote_addr;
?? ??? ?proxy_set_header REMOTE-HOST $remote_addr;
?? ??? ?proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
?? ??? ?proxy_pass http://localhost:30001/;
? ? ? ? }
? ? ? ? error_page ? 500 502 503 504 ?/50x.html;
? ? ? ? location = /50x.html {
? ? ? ? ? ? root ? html;
? ? ? ? }
? ? }?? ?

然后執(zhí)行nginx -s reload 重新加載nginx配置即可

備注:因為vue打包將index.html中css,圖片的路徑都加了publicPath這個參數(shù)值,在訪問頁面會出現(xiàn)找不到資源的情況,這種情況下,只需要在你的項目目錄下創(chuàng)建這個路徑,然后將static目錄拷貝進去即可

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

  • vue查詢數(shù)據(jù)el-table不更新數(shù)據(jù)的解決方案

    vue查詢數(shù)據(jù)el-table不更新數(shù)據(jù)的解決方案

    這篇文章主要介紹了vue查詢數(shù)據(jù)el-table不更新數(shù)據(jù)的問題及解決方案,本文通過示例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-12-12
  • element上傳文件對格式限制的處理方案

    element上傳文件對格式限制的處理方案

    最近做項目遇到這樣的需求,需要上傳的文件格式必須是pdf格式,方便我們查看,本文給大家分享element上傳文件對格式限制的處理方案,感興趣的朋友一起看看吧
    2024-02-02
  • vue3?js配置@符作為根路徑的詳細代碼示例

    vue3?js配置@符作為根路徑的詳細代碼示例

    這篇文章主要介紹了vue3?js配置@符作為根路徑的相關資料,通過示例代碼介紹了如何通過配置jsconfig.json/tsconfig.json及構(gòu)建工具(Vite/Webpack)設置別名,使@符號指向src目錄,簡化模塊導入路徑,提升代碼可讀性和維護性,需要的朋友可以參考下
    2025-05-05
  • vue keep-alive 動態(tài)刪除組件緩存的例子

    vue keep-alive 動態(tài)刪除組件緩存的例子

    今天小編就為大家分享一篇vue keep-alive 動態(tài)刪除組件緩存的例子,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-11-11
  • Vue中插入HTML代碼的方法

    Vue中插入HTML代碼的方法

    這篇文章主要介紹了Vue中插入HTML代碼的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-09-09
  • vue函數(shù)input輸入值請求時延遲1.5秒請求問題

    vue函數(shù)input輸入值請求時延遲1.5秒請求問題

    這篇文章主要介紹了vue函數(shù)input輸入值請求時延遲1.5秒請求問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • Vue中使用v-print打印出現(xiàn)空白頁問題及解決

    Vue中使用v-print打印出現(xiàn)空白頁問題及解決

    這篇文章主要介紹了Vue中使用v-print打印出現(xiàn)空白頁問題及解決方案,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-09-09
  • vue組件講解(is屬性的用法)模板標簽替換操作

    vue組件講解(is屬性的用法)模板標簽替換操作

    這篇文章主要介紹了vue組件講解(is屬性的用法)模板標簽替換操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-09-09
  • Vue遞歸實現(xiàn)樹形菜單方法實例

    Vue遞歸實現(xiàn)樹形菜單方法實例

    學習vue有一段時間了,最近使用vue做了一套后臺管理系統(tǒng),其中使用最多就是遞歸組件,下面這篇文章主要給大家介紹了關于Vue利用遞歸實現(xiàn)樹形菜單的相關資料,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考下
    2018-11-11
  • Vue實現(xiàn)快捷鍵錄入功能的示例代碼

    Vue實現(xiàn)快捷鍵錄入功能的示例代碼

    有的時候項目需要在頁面使用快捷鍵,而且需要對快捷鍵進行維護。本文將為大家展示Vue實現(xiàn)快捷鍵錄入功能的示例代碼,感興趣的可以了解一下
    2022-04-04

最新評論

中山市| 保靖县| 黑河市| 贵州省| 同德县| 姚安县| 资源县| 隆昌县| 荔波县| 通许县| 江门市| 霍林郭勒市| 临桂县| 大关县| 兴国县| 吉木乃县| 土默特右旗| 阿拉尔市| 陆河县| 济宁市| 左云县| 涟源市| 保德县| 娄底市| 文山县| 东宁县| 商河县| 毕节市| 财经| 磐安县| 马龙县| 高雄市| 无锡市| 紫金县| 阿克苏市| 喀喇沁旗| 花垣县| 六枝特区| 托克逊县| 育儿| 玉屏|