1.下载pcre
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.gz
tar -xvf pcre-8.33.tar.gz
2.下载nginx upload插件
wget https://github.com/vkholodkov/nginx-upload-module/archive/2.2.zip
unzip 2.2
解压出nginx-upload-module-2.2
3.下载tcp模块
wget https://github.com/yaoweibin/nginx_tcp_proxy_module/archive/master.zip
unzip nginx_tcp_proxy_module-master.zip
4.安装nginx
wget http://nginx.org/download/nginx-1.5.7.tar.gz
tar -xvf nginx-1.5.7.tar.gz
cd nginx-1.5.7
patch -p1 < ../nginx_tcp_proxy_module-master/tcp.patch
./configure \
--error-log-path=/usr/local/nginx/logs/error.log \
--http-log-path=/usr/local/nginx/logs/access.log \
--pid-path=/usr/local/nginx/logs/nginx.pid \
--lock-path=/usr/local/nginx/logs/nginx.lock \
--sbin-path=/usr/local/nginx/sbin/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--with-http_ssl_module \
--with-pcre=../pcre-8.33 \
--add-module=../nginx-upload-module-2.2
--add-module=../nginx_tcp_proxy_module-master
------
-配置-
------
tcp {
timeout 1d;
proxy_read_timeout 10d;
proxy_send_timeout 10d;
proxy_connect_timeout 30;
upstream cluster {
server localhost:8891;
server localhost:8892;
server localhost:8893;
check interval=10000 rise=2 fall=5 timeout=1000;
}
server {
listen 192.168.164.139:8899;
#server_name 192.168.164.139;
so_keepalive on;
tcp_nodelay on;
proxy_pass cluster;
}
upstream cluster1 {
server localhost:8791;
server localhost:8792;
server localhost:8793;
check interval=10000 rise=2 fall=5 timeout=1000;
}
server {
listen 192.168.164.188:8899;
#server_name 192.168.164.188;
so_keepalive on;
tcp_nodelay on;
proxy_pass cluster1;
}
}
server_name 好像不起作用
配置为
listen 192.168.164.188:8899;
起作用
本示例需要开启虚拟ip192.168.164.188(参看http://ontheroad-luckhouge.iteye.com/admin/blogs/2026898)
代理了两个服务,根据server ip区分