Configuring cluster load Balancing with NGINX+TOMCAT under Windows

Source: Internet
Author: User
Tags windows download


Nginx is a lightweight Web server/reverse proxy server, more detailed interpretation of their own Baidu. At present, such as Sina, NetEase and so on are using it. First of all, my server Software environment:

System: windows_server_2008_standard_enterprise_and_datacenter_with_sp2_x64

Currently running Tomcat: non-installable version of Tomcat 6.0.36

Just say these two key points, the problem is that the number of visits to a single tomcat has been unable to load, often a time-out situation. So the plan to use Nginx layout load balancer, the data found on the network is the introduction of the Linux version of Nginx layout and use, but in Windows if the use of Linux version of Nginx can only do a test, the actual production environment is not available, will report the following error:

Maximum number of descriptors supported by select () is 1024x768 while waiting for request

This is because the number of file access handles is limited to 1024 and will not respond when the traffic is large. Go to the Internet have looked up a lot of information that is modified parameters worker_connections can solve this limitation, there are many other said to modify worker_rlimit_nofile parameters, etc., have tried but all failed. In the preparation of other tools in a foreign forum to see a reply, the address does not remember, said that there is a special version of the Windows Nginx, has modified the file handle data restrictions. After downloading, it is true that the configuration runs OK successfully. As long as the download to the correct version of the configuration is still easy. The following is the download configuration process ha ~ ~

Nginx for Windows official website: http://nginx-win.ecsds.eu/

Nginx for Windows download address: http://nginx-win.ecsds.eu/download/

I downloaded the nginx 1.7.7.1 whiterabbit.zip This version, too new version I am afraid of instability. After download, unzip the installation package, there is a brief update information and Installation Guide Readme Nginx-win version.txt. Key information is as follows:

Default installation instructions;* New:unzip This version with folder structure* Old:overwrite with this version* C Heck nginx.conf, nginx-org.conf and nginx-win.conf* Windows optimization registry File:check your current values before s Etting the new ones
Locate the nginx-win.conf in the Conf folder, copy it to nginx.conf, and then configure it in this file, my configuration file is as follows:

#user nobody;# Multiple workers works!# number of worker processes: This value is configured based on the number of server CPU cores, such as the 6-core 12-thread CPU can be configured to 6 or 12. Worker_processes 6, #错误日志存放路径 #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log inf    o; #pid logs/nginx.pid;events {#设置单个进程同时打开的最大连接数, this value is set larger to accept more connections, of course, this requires CPU and memory support OH ~ ~ Worker_connections 32768; # max value 32768, nginx recycling connections+registry optimization = # This.value * = max concurrent Connection s currently tested with one worker # c1000k should being possible depending there is enough ram/cpu power # MULTI_ACC EPT on;}    HTTP {#include/nginx/conf/naxsi_core.rules;    Include Mime.types;    Default_type Application/octet-stream; #log_format Main ' $remote _addr: $remote _port-$remote _user [$time _local] "$request" ' # ' $status $bo    Dy_bytes_sent "$http _referer" ' # ' "$http _user_agent" $http _x_forwarded_for "; #access_log logs/access.log main;# # loadbalancing php#    Upstream Myloadbalancer {# server 127.0.0.1:9001 weight=1 fail_timeout=5;# server 127.0.0.1:9002 weigh T=1 fail_timeout=5;# Server 127.0.0.1:9003 weight=1 fail_timeout=5;# server 127.0.0.1:9004 weight=1 fail_t          imeout=5;# server 127.0.0.1:9005 weight=1 fail_timeout=5;# server 127.0.0.1:9006 weight=1 fail_timeout=5;# Server 127.0.0.1:9007 weight=1 fail_timeout=5;# server 127.0.0.1:9008 weight=1 fail_timeout=5;# s erver 127.0.0.1:9009 weight=1 fail_timeout=5;# server 127.0.0.1:9010 weight=1 fail_timeout=5;# least_conn; #}# The Tomcat server information is set here, and Tomcat may not be on the same host. There are two Tomcat services set up here, with a weighting of 1:1.           LocalHost is replaced with the server IP upstream localhost{#ip_hash;           Server 127.0.0.1:9010 weight=1;         Server 127.0.0.1:9020 weight=1;    } sendfile off;    #tcp_nopush on;    Server_names_hash_bucket_size 128;## start:timeouts # # Client_body_timeout 10;  Client_header_timeout 10;  Keepalive_timeout 80;    Send_timeout 10;    Keepalive_requests 10;## end:timeouts # # #gzip on;        server {#这个很关键 ~ ~ It is the port of Nginx listening Oh ~ ~ Listen 8080;        server_name localhost;        #charset Koi8-r; #access_log logs/host.access.log main;# for naxsi Remove the "single" line for learn mode, or the "# Lines for" full WAF            Mode location/{#include/nginx/conf/mysite.rules; # See also HTTP block naxsi include line          # #SecRulesEnabled;          # #DeniedUrl "/requestdenied";          # #CheckRule "$SQL >= 8" BLOCK;          # #CheckRule "$RFI >= 8" BLOCK;          # #CheckRule "$TRAVERSAL >= 4" BLOCK;              # #CheckRule "$XSS >= 8" BLOCK;            Proxy_pass http://localhost;            root HTML;        Index index.html index.htm;  }# for Naxsi Remove the # lines for full WAF mode, redirect location block used by Naxsi # #location/requestdenied    {# # return 412;    ##}## Lua Examples!# location/robots.txt {# Rewrite_by_lua ' # if Ngx.var.http_host ~=        "localhost" then# return ngx.exec ("/robots_disallow.txt"); # end# '; #}        #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$ {# ProX        Y_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; # single Backend process # Fastcgi_pass Myloadbalancer;        # or multiple, see example above # Fastcgi_index index.php;  # Fastcgi_param Script_filename$document _root$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 SSL spdy;    # server_name localhost;    # SSL on;    # ssl_certificate Cert.pem;    # Ssl_certificate_key Cert.key;    # ssl_session_timeout 5m;    # ssl_prefer_server_ciphers on;    # ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; # ssl_ciphers Ecdh+aesgcm:dh+aesgcm:ecdh+aes256:dh+aes256:ecdh+aes128:dh+aes:ecdh+3des:dh+3des:rsa+aesgcm:rsa+aes:rsa+3des:!anull:!enull:! md5:!    DSS;    # location/{# root HTML;    # index index.html index.htm; #    }    #}}


The configuration of Tomcat is relatively simple, it is to copy a change three ports. Specific own Baidu.

Configuration is complete, run Nginx.exe and Tomcat to verify the configuration.

Nginx Start-up control I used a friend's script on the Internet, the address is as follows:

http://feitianbenyue.iteye.com/blog/1989868






Configuring cluster load Balancing with NGINX+TOMCAT under Windows

Related Article

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.