欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue項(xiàng)目nginx二級(jí)域名配置方式

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

vue項(xiàng)目nginx二級(jí)域名配置

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

在這里插入圖片描述

2、配置nginx,下圖所示

在這里插入圖片描述

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

在這里插入圖片描述

在這里插入圖片描述

nginx多個(gè)vue項(xiàng)目使用獨(dú)立二級(jí)域名部署

因?yàn)轫?xiàng)目前后端分離部署,多個(gè)項(xiàng)目前端使用同一個(gè)nginx發(fā)布,每個(gè)項(xiàng)目對(duì)應(yīng)不同的二級(jí)域名

  • dsp項(xiàng)目  : dsp.xxxx.com
  • bi項(xiàng)目:bi.xxxx.com

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

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

2.修改項(xiàng)目router的base

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

3.修改.env.production

##這個(gè)地方改成每個(gè)項(xiàng)目不一樣就行了
VUE_APP_BASE_API = '/prod'

4.然后將項(xiàng)目打包

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

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;
? ? #這個(gè)地方是我自己建了一個(gè)目錄,兩個(gè)項(xiàng)目分別在這個(gè)目錄下建自己的配置文件
? ? 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項(xiàng)目目錄
?? ??? ??? ?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;
? ? ? ? ? ? ##后端服務(wù)的地址
?? ??? ??? ?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配置即可

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

總結(jié)

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

相關(guān)文章

  • 關(guān)于Element-UI中slot的用法及說(shuō)明

    關(guān)于Element-UI中slot的用法及說(shuō)明

    這篇文章主要介紹了關(guān)于Element-UI中slot的用法及說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-10-10
  • Vue實(shí)現(xiàn)紅包雨小游戲的示例代碼

    Vue實(shí)現(xiàn)紅包雨小游戲的示例代碼

    紅包也叫壓歲錢,是過(guò)農(nóng)歷春節(jié)時(shí)長(zhǎng)輩給小孩兒用紅紙包裹的禮金。本文將通過(guò)Vue制作一個(gè)紅包雨小游戲,文中的示例代碼講解詳細(xì),需要的可以參考一下
    2022-01-01
  • vue實(shí)現(xiàn)彈幕功能

    vue實(shí)現(xiàn)彈幕功能

    這篇文章主要介紹了vue實(shí)現(xiàn)彈幕功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-10-10
  • Vue的Class與Style綁定的方法

    Vue的Class與Style綁定的方法

    本篇文章主要介紹了Vue的Class與Style綁定的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-09-09
  • Vue腳手架搭建及創(chuàng)建Vue項(xiàng)目流程的詳細(xì)教程

    Vue腳手架搭建及創(chuàng)建Vue項(xiàng)目流程的詳細(xì)教程

    Vue腳手架指的是vue-cli,它是一個(gè)快速構(gòu)建**單頁(yè)面應(yīng)用程序(SPA)**環(huán)境配置的工具,cli是(command-line-interfac)命令行界面,下面這篇文章主要給大家介紹了關(guān)于Vue腳手架搭建及創(chuàng)建Vue項(xiàng)目流程的相關(guān)資料,需要的朋友可以參考下
    2022-09-09
  • vue style width a href動(dòng)態(tài)拼接問(wèn)題的解決

    vue style width a href動(dòng)態(tài)拼接問(wèn)題的解決

    這篇文章主要介紹了vue style width a href動(dòng)態(tài)拼接問(wèn)題的解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-08-08
  • vue實(shí)現(xiàn)吸壁懸浮球

    vue實(shí)現(xiàn)吸壁懸浮球

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)吸壁懸浮球,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • vue2里面ref的具體使用方法

    vue2里面ref的具體使用方法

    本篇文章主要介紹了vue2里面ref的具體使用方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-10-10
  • vuex 中輔助函數(shù)mapGetters的基本用法詳解

    vuex 中輔助函數(shù)mapGetters的基本用法詳解

    mapGetters輔助函數(shù)僅僅是將 store 中的 getter 映射到局部計(jì)算屬性,在組件或界面中不使用mapGetter調(diào)用映射vuex中的getter,在組件或界面中使用mapGetter調(diào)用映射vuex中的getter,具體內(nèi)容跟隨小編一起通過(guò)本文學(xué)習(xí)吧 
    2021-07-07
  • vue3.0實(shí)踐之寫tsx語(yǔ)法實(shí)例

    vue3.0實(shí)踐之寫tsx語(yǔ)法實(shí)例

    很久不寫博客了,最近在使用ts和tsx開發(fā)vue類項(xiàng)目,網(wǎng)上資料比較少,順便記錄一下方便同樣開發(fā)的人互相學(xué)習(xí)共同進(jìn)步,下面這篇文章主要給大家介紹了關(guān)于vue3.0實(shí)踐之寫tsx語(yǔ)法的相關(guān)資料,需要的朋友可以參考下
    2022-07-07

最新評(píng)論