static-nginx
yml
services:
static-nginx:
image: nginx:1.27-alpine
container_name: static-nginx
restart: unless-stopped
volumes:
- /opt/frontend-dist:/usr/share/nginx/html:ro
- ./conf.d:/etc/nginx/conf.d:ro
networks:
- traefik
networks:
traefik:
external: trueconf.d/default.conf:
nginx
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
include /etc/nginx/conf.d/spa/*.conf;
}需要注意目录是 ./conf.d/spa/*.conf,
如:./conf.d/spa/panorama.conf 内容是
location = /p {
return 301 /panorama/;
}
location = /panorama {
return 301 /panorama/;
}
location /panorama/ {
try_files $uri $uri/ /panorama/index.html;
}