1.下载nginx_substitutions_filter并解压
git clone git://github.com/yaoweibin/ngx_http_substitutions_filter_module.git
2.安装nginx
wget http://nginx.org/download/nginx-1.4.2.tar.gz
3.编译安装
sudo ./configure --prefix=/usr/local/nginx --pid-path=/usr/local/nginx.pid --with-http_dav_module --with-http_flv_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-debug --add-module=/home/spark/ngx_http_substitutions_filter_module/ //这是模块解压的路径
sudo make
sudo make install
4.配置nginx.conf
upstream master {
server 172.16.236.128:8080;
}
upstream master2 {
server 172.16.236.128:8088;
}
upstream master3 {
server 172.16.236.129:4040;
}
upstream h102 {
server 172.16.236.129:8042;
}
upstream h103 {
server 172.16.236.130:8042;
}
upstream h104 {
server 172.16.236.131:8042;
}
upstream h105 {
server 172.16.236.132:8042;
}
upstream h106 {
server 172.16.236.133:8042;
}
upstream h107 {
server 172.16.236.134:8042;
}
upstream h108 {
server 172.16.236.135:8042;
}
upstream h109 {
server 172.16.236.136:8042;
}
upstream h110 {
server 172.16.236.137:8042;
}
upstream h111 {
server 172.16.236.138:8042;
}
server {
listen 8080;
location / {
proxy_pass http://master;
}
}
server {
listen 8088;
location / {
proxy_pass http://master2;
}
}
server {
listen 4040;
location / {
proxy_pass http://master3;
}
}
server {
listen 8042;
location / {
proxy_pass http://h102;
}
}
server {
listen 8043;
location / {
proxy_pass http://h103;
}
}
server {
listen 8044;
location / {
proxy_pass http://h104;
}
}
server {
listen 8045;
location / {
proxy_pass http://h105;
}
}
server {
listen 8046;
location / {
proxy_pass http://h106;
}
}
server {
listen 8047;
location / {
proxy_pass http://h107;
}
}
server {
listen 8048;
location / {
proxy_pass http://h108;
}
}
server {
listen 8049;
location / {
proxy_pass http://h109;
}
}
server {
listen 8050;
location / {
proxy_pass http://h110;
}
}
server {
listen 8051;
location / {
proxy_pass http://h111;
}
}
最后重载配置文件
sudo /usr/local/nginx/sbin/nginx -s reload
通过服务器地址+端口号即可访问内网集群的对应网址