Use Nginx server load balancer to build high-performance. NETweb application 2

Source: Internet
Author: User
Tags to domain
: This article describes how to use Nginx server load balancer to build a high-performance. NETweb application 2. if you are interested in PHP tutorials, refer to it. In this article, we use Nginx server load balancer to build high performance. in NETweb Application 1, we have a preliminary understanding of Nginx. next we will deploy our web application in the Nginx demonstration cluster on the windows platform.


1. download the Nginx deployment package

To Nginx official website to download a windows platform below the Nginx deployment package, I download is a nginx-1.6.2 version.


II. command to start the service
Start: start nginx.exe
Stop: nginx-s stop

Reload: nginx-s reload


III. instance construction
First choice: we need to deploy our web applications on our iis, deploy them on different machines, and set the corresponding ip address and port number, because I simulated the results on the local machine, I deployed two web applications on the local iis, and the first web application was deployed on the localhost: 8011 port, the second application is deployed on the localhost: Port 8012. in order to see the demonstration result, we marked the WebForm1.aspx page as the page of the web applications, in practice, we do not need to deploy the system. we deploy one of our web applications to servers on different machines, as shown below.

Web Application 1 Address: http: // localhost: 8011/WebForm1.aspx
Web Application 2 Address: http: // localhost: 8012/WebForm1.aspx

(1) start the Nginx service

(2) modify the Nginx configuration item. for detailed configuration instructions, describe the parameter setting department and verify whether the service is started properly.

(3) http: // localhost: 8010/WebForm1.aspx


(4) in this way, we can simulate the load balancing effect. OK

IV. other instructions

(1) configure domain name access: first, we need to add domain name settings in Nginx, and then we need to set 127.0.0.1 ING to domain name on the local machine

In this way, we can access: http: // huangxiang: 8010/WebForm1.aspx.

(2) configure the number of processes started by Ngnix. we can pay attention to the changes in the number of processes in the process.


V. parameter settings

# Define the user and user group for running Nginx # user nobody; # Number of Nginx processes. it is recommended that worker_processes 2 be consistent with the total cpu kernel; # error_log logs/error. log; # error_log logs/error. log notice; # error_log logs/error. log info; # pid logs/nginx. pid; events {# defines the maximum number of connections of a single process (the actual maximum number of connections is divided by 2) worker_connections 1024;} # defines http server http {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 on; # tcp_nopush on; # keepalive_timeout 0; keepalive_timeout 65; # gzip on; # server cluster upstream huangxiang.com {# server cluster name # server 172.16.21.13: 8081 weight = 1; # the server configuration weight indicates the weight. the higher the weight, the higher the probability of allocation. # Server 192.168.1.186: 8081 weight = 1; # server 172.16.1.14: 8081 weight = 2; # server 172.16.1.15: 8081 weight = 1; # server 172.16.1.15: 80 weight = 1; server 127.0.0.1: 8011 weight = 1; server 127.0.0.1: 8012 weight = 2 ;}# virtual machine host configuration server {listen 8010; # port number server_name localhost huangxiang.com; # multiple domain names can exist, separate multiple with spaces # charset KOI8-R; # access_log logs/host. access. log main; # location/{# root html; # index index.html index.htm; #} location/{proxy_pass http://huangxiang.com ; Proxy_redirect default ;}# error_page 404/404 .html; # redirect server error pages to the static page/50x.html # error_page 500 502 503 x.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. htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\. 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; # server_name localhost; # ssl_certificate cert. pem; # ssl_certificate_key cert. key; # ssl_se Ssion_cache shared: SSL: 1 m; # ssl_session_timeout 5 m; # ssl_ciphers HIGH :! ANULL :! MD5; # ssl_prefer_server_ciphers on; # location/{# root html; # index index.html index.htm ;#}#}}



The above describes how to use Nginx server load balancer to build a high-performance. NETweb application 2, including some content, and hope to help friends who are interested in PHP tutorials.

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.