54 lines
1.4 KiB
Bash
54 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
# 在 192.168.3.132 上执行
|
|
|
|
# 1. 创建配置目录
|
|
mkdir -p /data/nginx-proxy
|
|
|
|
# 2. 写入 nginx 配置
|
|
cat > /data/nginx-proxy/nginx.conf << 'EOF'
|
|
worker_processes auto;
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
include mime.types;
|
|
default_type application/octet-stream;
|
|
sendfile on;
|
|
keepalive_timeout 65;
|
|
client_max_body_size 100M;
|
|
|
|
server {
|
|
listen 8080;
|
|
|
|
# 前端
|
|
location / {
|
|
proxy_pass http://192.168.3.132:8081/;
|
|
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 ~ ^/(common|order|supplier|contract|base|export-app|auth|user|system|api|ws|return|returnVehicle|returnOrder|supplierManage|agg-api|zgs|gps|data-search)/ {
|
|
proxy_pass http://192.168.3.132:28092;
|
|
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 Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
|
|
# 3. 启动 nginx 容器
|
|
docker run -d \
|
|
--name nginx-proxy \
|
|
--restart always \
|
|
-p 8080:8080 \
|
|
-v /data/nginx-proxy/nginx.conf:/etc/nginx/nginx.conf:ro \
|
|
nginx:alpine
|