Set Nginx load balancer under Windows

Source: Internet
Author: User

#user nobody; #指定nginx进程数worker_processes1; #全局错误日志及PID文件 #error_log logs/Error.log, #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/Nginx.pid; Events {# Number of connections Max Worker_connections1024x768;}    #设定http服务器, using its reverse proxy feature to provide load balancing support for HTTP {#设定mime类型, the type is defined by the Mime.type file include mime.types; Default_type Application/octet-stream; #设定日志格式 #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;    #sendfile instruction Specifies whether Nginx calls the Sendfile function (zero copy mode) to output the file, for general applications, sendfile on;    #tcp_nopush on; #连接超时时间 #keepalive_timeout0; Keepalive_timeout $;    #开启gzip压缩 #gzip on;    #设定负载均衡的服务器列表 support multiple sets of load balancing, you can configure multiple upstream to serve different servers. #nginx upstream supports several ways of assigning #1), polling (default) each request is assigned to a different back-end server in chronological order, and can be automatically rejected if the backend server is down. #2), weight specifies the polling probability, the weight is proportional to the access ratio, and is used in cases where the performance of the backend server is uneven.    With the above sample, the weights are specified. #3), ip_hash each request according to the hash result of the access IP allocation, so that each visitor fixed access to a back-end server, can solve the session problem. #4), Fair #5), Url_hash #Urlhash upstream Mysvr {#weigth参数表示权值, the higher the weight, the greater the chance of being assigned to it.1. Down indicates that a pre-order server is temporarily not participating in the payload #2. Weight the larger the default is 1.weight, the greater the load weight. #3. Backup: When all other non-backup machines are down or busy, request the backup machine.        So the pressure on this machine is the lightest. #server192.168.1.116Down ; #server192.168.1.116backup; Server192.168.1.121weight=1; Server192.168.1.122weight=2; } #配置代理服务器的地址, the server address of the Nginx installation, the listening port, the default address server {#1. Listening on port 80 Listen the;                #对于server_name, if you need to reverse proxy multiple domain name requests, you can configure multiple server_name to meet the requirements server_name localhost; #charset Koi8-R; #access_log logs/Host.access.log Main; Location/{# Default home directory in the HTML subdirectory of the Nginx installation directory.            root HTML;                       Index index.html index.htm; Proxy_pass http://mysvr; #跟载均衡服务器的upstream对应} #error_page404/404. html; # REDIRECT Server error pages to theStaticPage/50x.html # # definition error prompt page #error_page - 502 503 504/50x.html; #location= /50x.html {# root HTML; #} # Proxy The PHP scripts to Apache listening on127.0.0.1: the# #location~\.php$ {# Proxy_pass http://127.0.0.1;#} # Pass the PHP scripts to FastCGI server listening on127.0.0.1:9000# #location~\.php$ {# root HTML; # Fastcgi_pass127.0.0.1:9000;        # Fastcgi_index index.php; # Fastcgi_param Script_filename/Scripts$fastcgi_script_name;        # include Fastcgi_params; #} # Deny access to. htaccess files,ifApache's Document Root# concurs with Nginx'S One# #location~ /\.ht {# deny all; #}} # anotherVirtualHostusingMix of ip-, name-, and port-based configuration # #server {# listen8000; # Listen Somename:8080;    # server_name somename alias Another.alias; # Location/{# root HTML;    # index index.html index.htm; #} #} # HTTPS Server # #server {# listen443SSL;    # server_name localhost;    # ssl_certificate Cert.pem;    # Ssl_certificate_key Cert.key;    # Ssl_session_cache shared:ssl:1m;    # ssl_session_timeout 5m; # Ssl_ciphers High:!anull:!MD5;    # ssl_prefer_server_ciphers on; # Location/{# root HTML;    # index index.html index.htm; #    }    #}}

Start Nginx

CMD into Nginx unzip directory to perform start Nginx start Nginx Service

How do I check if it started successfully after startup? Enter the command tasklist/fi "imagename eq nginx.exe" and see the following message stating that the launch was successful

Set Nginx load balancer under Windows

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.