将前后端分离的代理独立出来,并解决了一系列nginx代理问题
This commit is contained in:
11
nginx/Dockerfile
Normal file
11
nginx/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
# 使用Nginx作为基础镜像
|
||||
FROM nginx:stable-alpine
|
||||
|
||||
# 复制Nginx配置文件
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# 暴露80端口
|
||||
EXPOSE 80
|
||||
|
||||
# 启动Nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
25
nginx/nginx.conf
Normal file
25
nginx/nginx.conf
Normal file
@@ -0,0 +1,25 @@
|
||||
worker_processes 1;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://backend:8000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://frontend:80/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user