docker-nginx-标记一下
拉取nginx镜像
然后启动容器:
docker run -p 80:80 --name mynginx -d -v $PWD/nginx.conf:/etc/nginx/conf.d/default.conf nginx:latest
$PWD/nginx.conf 把当前目录下的nginx.conf配置文件挂载到 容器的/etc/nginx/conf.d/default.conf
nginx.conf文件:
map $http_upgrade $connection_upgrade { default upgrade; '' close; proxy_ignore_client_abort on; } server { listen 80; server_name localhost; location / { proxy_pass http://192.168.1.164:9001; proxy_set_header Host $proxy_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }