docker运行nginx实现TCP代理
1、安装docker和docker-compose
步骤略
2、任意目录创建docker-compose.yml文件
touch docker-compose.yml
touch nginx.conf
3、修改docker-compose.yml 文件
version: '3'
services:
nginx:
image: nginx
container_name: tcpnginx
network_mode: host
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
4、在同目录创建nginx.conf
events {}
stream {
server {
listen 41860;
proxy_pass 172.16.22.203:9000;
}
}
运行docker-compose up -d