nginxで複数ポート(9000、9001、9002、9003)を起動する方法
1.複数ポート
ポート番号9000 9001 9002 9003
2.システム環境
CentOS 6.5 64ビット
nginx1.9.11
3.nginx.conf の設定
stream {
upstream 9000 {
hash $remote_addr consistent;
server 172.17.2.101:9000 max_fails=3 fail_timeout=30s;
}
upstream 9001 {
hash $remote_addr consistent;
server 172.17.2.101:9001 max_fails=3 fail_timeout=30s;
}
upstream 9002 {
hash $remote_addr consistent;
server 172.17.2.101:9002 max_fails=3 fail_timeout=30s;
}
upstream 9003 {
hash $remote_addr consistent;
server 172.17.2.101:9003 max_fails=3 fail_timeout=30s;
}
server {
listen 9000;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 9000;
}
server {
listen 9001;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 9001;
}
server {
listen 9002;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 9002;
}
server {
listen 9003;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 9003;
}
}
4.nginx再起動
#pkill -9 nginx
# /usr/local/nginx/sbin/nginx