Nginx 部署
1. Docker部署
A. 注意点:该方式部署会存在无法获取真实IP的情况,解决办法是下面的方式,不过docker stack这样部署有局限性,端口映射到宿主机,一个宿主机只能运行一个副本,同一个宿主机不能运行多个副本,会导致端口冲突;
B. stack.yml配置文件
version: '3.8' networks: rhxy-net: external: true volumes: nginx-logs: services: # nginx代理 nginx: image: nginx:latest deploy: mode: global placement: constraints: [node.role == manager] ports: - target: 80 published: 80 mode: host - target: 443 published: 443 mode: host - target: 443 published: 443 protocol: udp mode: host networks: - rhxy-net volumes: - /etc/localtime:/etc/localtime - /data/nfs/nginx/nginx.conf:/etc/nginx/nginx.conf - /data/nfs/nginx/conf.d/:/etc/nginx/conf.d/ - /app/ui/:/app/ui/ - nginx-logs:/var/log/nginx/