docker pull nginx
#运行nginx容器
docker run -id --name mynginx -p 8080:80 nginx
#将配置文件从容器内拷贝至本地
docker cp 容器ID:/etc/nginx/nginx.conf /data01/nginx/
docker cp 容器ID:/usr/share/nginx/html /data01/nginx/
#将容器删除
docker stop 容器ID
docker rm 容器ID
docker run -id --name mynginx --net host -v /data01/nginx/nginx.conf:/etc/nginx/nginx.conf -v /data01/nginx/conf.d:/etc/nginx/conf.d nginx
vim zabbix.conf
server {
listen 8110;
#server_name zabbix.test.com;
access_log /var/log/nginx/zabbix.access.log;
error_log /var/log/nginx/zabbix.error.log;
location / {
proxy_pass http://10.175.246.31;
#proxy_http_version 1.1;
#proxy_buffering off;
#proxy_request_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Cookie $http_cookie;
#proxy_redirect off;
}
}
[root@dock-appla01 /]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8110 0.0.0.0:* LISTEN 19558/nginx: master
tcp 0 0 0.0.0.0:8111 0.0.0.0:* LISTEN 19558/nginx: master
tcp 0 0 0.0.0.0:8112 0.0.0.0:* LISTEN 19558/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 27419/sshd