目录结构
webdata
└── front-lib-web
├── conf.d
│ └── default.conf
├── docker-compose.yml
└── html
└── frontDemo
* conf.d/default.conf
server {
listen 6888;
server_name localhost;
access_log /var/log/nginx/host.access.log main;
error_log /var/log/nginx/error.log error;
location / {
root /usr/share/nginx/html/frontDemo;
index /frontDemo/index.html index.htm;
try_files $uri $uri/ /frontDemo/index.html;
}
location /frontDemo {
root /usr/share/nginx/html;
index /frontDemo/index.html index.htm;
try_files $uri $uri/ /frontDemo/index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
* docker-compose.yml
version: "3"
services: #指定服务名称
web-service:
container_name: front-lib-web #指定容器名称
ports:
- "6888:6888" # 左侧为docker暴露端口 右侧为nginx端口(服务器端口)
image: nginx:latest #nginx镜像
volumes: # volumes挂载方式
- ./html:/usr/share/nginx/html # 挂载dist静态资源到容器中 ./当前目录
- ./conf.d:/etc/nginx/conf.d # 挂载nginx配置文件的目录到容器,替换nginx容器中的默认配置目录
restart: always # 重启策略:容器退出时重启容器
标签:index,compose,log,frontDemo,Vue,nginx,html,conf,docker
From: https://www.cnblogs.com/openmind-ink/p/18222421