A NIGNX service reverse proxy 3 IP Access configuration method

Source: Internet
Author: User

Scenario: Deploy a Web project in the 10.17.55,44:7002 and 10.17.55.46:7003 WebLogic, ready for load balancing. In a ip:12.17.56.44 can access to 55.44 and 55.46 Web works on the machine to do Nginx proxy server, the proxy port is 7000, both 12.17.56.44:7000 can access to 10.17.55,44:7002 or 10.17.55.46:7003 Web works, and the internet has a ip22.18.55.33:7000 that can be accessed,12.17.56.44:7000, 12.17.56.44 The nginx.conf content of this server is configured as follows:

#user nobody;worker_processes Auto; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.    Log info; #pid logs/nginx.pid;events {worker_connections 2048;    Accept_mutex off;     Multi_accept on; Use Epoll; }# load modules compiled as Dynamic Shared Object (DSO) # #dso {# load ngx_http_fastcgi_module.so;# load NGX_HTTP_REWR    ite_module.so;#} #thread_pool One threads=128 max_queue=0;http {include mime.types;    Default_type Application/octet-stream;     #thread_pool one threads=128 max_queue=0;include/etc/nginx/mutnginx/*.conf;  #log_format Main ' $remote _addr-$remote _user [$time _local] "$request" ' # ' $status $body _bytes_sent    "$http _referer" ' # ' "$http _user_agent" "$http _x_forwarded_for";    #access_log Logs/access.log Main;    Access_log off;    Sendfile on;    #tcp_nopush on;    Sendfile_max_chunk 512k;    #keepalive_timeout 0;   Keepalive_timeout 65; Upstream CLuster1 {# simple round-robin ip_hash;server 10.17.55,44:7002;          Server 10.17.55.46:7003;    } #gzip on;    server {listen 7000;server_name localhost;        # 0.99.132.52:700#check interval=30 #charset koi8-r;        #access_log Logs/host.access.log Main;         Location/{#aio threads=one;        Proxy_set_header Host $host: 7000;              Proxy_set_header x-real-ip $remote _addr;proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;        Proxy_buffering off;   Proxy_pass http://cluster1/;           # root HTML;        #index index.html index.htm;            } location/status {#check_status;            Access_log off;           Allow all;        # Deny All;        } #error_page 404/404.html;        # REDIRECT Server error pages to the static page/50x.html # Error_page 502 503 504/50x.html;     Location =/50x.html {root html;   } # Proxy The PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ {# p        Roxy_pass http://127.0.0.1;        #} # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ {        # root HTML;        # Fastcgi_pass 127.0.0.1:9000;        # Fastcgi_index index.php;        # Fastcgi_param Script_filename/scripts$fastcgi_script_name;        # include Fastcgi_params; #} # Deny access to. htaccess files, if Apache ' s document Root # concurs with Nginx ' s one # #l        ocation ~/\.ht {# deny all;       #}} # Another virtual host using mix of ip-, name-, and port-based configuration # #server {# listen    8000;    # Listen somename:8080;    # server_name somename alias Another.alias;    # location/{# root HTML;    # index index.html index.htm;    #} #} # HTTPS Server # #server {# listen 443;    # server_name localhost;    # SSL on;    # ssl_certificate Cert.pem;    # Ssl_certificate_key Cert.key;    # ssl_session_timeout 5m;    # ssl_protocols SSLv2 SSLv3 TLSv1; # ssl_ciphers high:!anull:!    MD5;    # ssl_prefer_server_ciphers on;    # location/{# root HTML;    # index index.html index.htm; #    }    #}}

In the configuration file:

In the Mutnginx directory, two files similar to nginx.conf are created.

The nginx2.conf configuration is intended to allow the same network segment , 12.17.56.* other applications, to access the Web project with the same proxy IP, which is configured as follows:

#user nobody;worker_processes Auto; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.    Log info; #pid logs/nginx.pid;events {worker_connections 2048;    Accept_mutex off;     Multi_accept on; Use Epoll; }# load modules compiled as Dynamic Shared Object (DSO) # #dso {# load ngx_http_fastcgi_module.so;# load NGX_HTTP_REWR    ite_module.so;#} #thread_pool One threads=128 max_queue=0;http {include mime.types;    Default_type Application/octet-stream;     #thread_pool one threads=128 max_queue=0;  #log_format Main ' $remote _addr-$remote _user [$time _local] "$request" ' # ' $status $body _bytes_sent    "$http _referer" ' # ' "$http _user_agent" "$http _x_forwarded_for";    #access_log Logs/access.log Main;    Access_log off;    Sendfile on;    #tcp_nopush on;    Sendfile_max_chunk 512k;    #keepalive_timeout 0;   Keepalive_timeout 65; Upstream Cluster3 {# simple Round-robIn Ip_hash;server 10.17.55,44:7002;          Server 10.17.55.46:7003;    } #gzip on;    server {listen 7000;server_name localhost;        # 0.99.132.52:700#check interval=30 #charset koi8-r;        #access_log Logs/host.access.log Main;         Location/{#aio threads=one;        Proxy_set_header Host $host: 7000;              Proxy_set_header x-real-ip $remote _addr;proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;        Proxy_buffering off;   Proxy_pass http://cluster3/;           # root HTML;        #index index.html index.htm;            } location/status {#check_status;            Access_log off;           Allow all;        # Deny All;        } #error_page 404/404.html;        # REDIRECT Server error pages to the static page/50x.html # Error_page 502 503 504/50x.html;        Location =/50x.html {root html; } # Proxy The PHP scripts To Apache listening on 127.0.0.1:80 # #location ~ \.php$ {# Proxy_pass http://127.0.0.1;        #} # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ {        # root HTML;        # Fastcgi_pass 127.0.0.1:9000;        # Fastcgi_index index.php;        # Fastcgi_param Script_filename/scripts$fastcgi_script_name;        # include Fastcgi_params; #} # Deny access to. htaccess files, if Apache ' s document Root # concurs with Nginx ' s one # #l        ocation ~/\.ht {# deny all;       #}} # Another virtual host using mix of ip-, name-, and port-based configuration # #server {# listen    8000;    # Listen somename:8080;    # server_name somename alias Another.alias;    # location/{# root HTML;    # index index.html index.htm; #} #} # HTTPS Server # #server {# listen 443;    # server_name localhost;    # SSL on;    # ssl_certificate Cert.pem;    # Ssl_certificate_key Cert.key;    # ssl_session_timeout 5m;    # ssl_protocols SSLv2 SSLv3 TLSv1; # ssl_ciphers high:!anull:!    MD5;    # ssl_prefer_server_ciphers on;    # location/{# root HTML;    # index index.html index.htm; #    }    #}}

There is also a nginx3.conf is to let, other intranet IP Unified Access agent, its configuration is as follows:

#user nobody;worker_processes Auto; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.    Log info; #pid logs/nginx.pid;events {worker_connections 2048;    Accept_mutex off;     Multi_accept on; Use Epoll; }# load modules compiled as Dynamic Shared Object (DSO) # #dso {# load ngx_http_fastcgi_module.so;# load NGX_HTTP_REWR    ite_module.so;#} #thread_pool One threads=128 max_queue=0;http {include mime.types;    Default_type Application/octet-stream;     #thread_pool one threads=128 max_queue=0;  #log_format Main ' $remote _addr-$remote _user [$time _local] "$request" ' # ' $status $body _bytes_sent    "$http _referer" ' # ' "$http _user_agent" "$http _x_forwarded_for";    #access_log Logs/access.log Main;    Access_log off;    Sendfile on;    #tcp_nopush on;    Sendfile_max_chunk 512k;    #keepalive_timeout 0;   Keepalive_timeout 65; Upstream Cluster2 {# simple Round-robIn Ip_hash;server 10.17.55,44:7002;          Server 10.17.55.46:7003;    } #gzip on;    server {listen 7000;server_name localhost;        # 0.99.132.52:700#check interval=30 #charset koi8-r;        #access_log Logs/host.access.log Main;         Location/{#aio threads=one;        Proxy_set_header Host $host: 5123;              Proxy_set_header x-real-ip $remote _addr;proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;        Proxy_buffering off;   Proxy_pass http://cluster2/;           # root HTML;        #index index.html index.htm;            } location/status {#check_status;            Access_log off;           Allow all;        # Deny All;        } #error_page 404/404.html;        # REDIRECT Server error pages to the static page/50x.html # Error_page 502 503 504/50x.html;        Location =/50x.html {root html; } # Proxy The PHP scripts To Apache listening on 127.0.0.1:80 # #location ~ \.php$ {# Proxy_pass http://127.0.0.1;        #} # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ {        # root HTML;        # Fastcgi_pass 127.0.0.1:9000;        # Fastcgi_index index.php;        # Fastcgi_param Script_filename/scripts$fastcgi_script_name;        # include Fastcgi_params; #} # Deny access to. htaccess files, if Apache ' s document Root # concurs with Nginx ' s one # #l        ocation ~/\.ht {# deny all;       #}} # Another virtual host using mix of ip-, name-, and port-based configuration # #server {# listen    8000;    # Listen somename:8080;    # server_name somename alias Another.alias;    # location/{# root HTML;    # index index.html index.htm; #} #} # HTTPS Server # #server {# listen 443;    # server_name localhost;    # SSL on;    # ssl_certificate Cert.pem;    # Ssl_certificate_key Cert.key;    # ssl_session_timeout 5m;    # ssl_protocols SSLv2 SSLv3 TLSv1; # ssl_ciphers high:!anull:!    MD5;    # ssl_prefer_server_ciphers on;    # location/{# root HTML;    # index index.html index.htm; #    }    #}}
which
Proxy_set_header Host $host: 5123; #是映射端口, if 12.17.56.44:7000 mapped IP is 102.34.56.44 then 5123 is the mapper 7000 port
Such
12.17.56.44
is an Internet IP 22.18.55.33:7000 and Intranet 12.17.56.44.:5213 and 12.17.56.44:7000 do a mapping agent, that is, these three IP can access to the Web project.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The above describes a NIGNX service reverse proxy 3 IP access configuration method, including the aspects of the content, I hope that the PHP tutorial interested friends helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.