docker compose added nginx revert proxy to port 80

This commit is contained in:
Tony 2024-05-24 10:08:55 +00:00
parent f98aaf323d
commit 27e2ee184a
2 changed files with 37 additions and 1 deletions

View File

@ -29,3 +29,14 @@ services:
- "5173:5173"
restart: always
nginx:
image: nginx:latest
depends_on:
- backend
- frontend
ports:
- "80:5173"
network_mode: host
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf # 挂载自定义的nginx配置文件

25
nginx.conf Normal file
View File

@ -0,0 +1,25 @@
events {}
http {
upstream backend {
least_conn;
server localhost:5173;
server localhost:5173;
}
server {
listen 80;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}