Nginx + IIS + Web front-end (Spring MVC)-load balancing (i)

Source: Internet
Author: User
Tags sendfile nginx server
Introduction

When we were developing large Web projects, if our web was published on a single server in IIS, when a large number of request-to-IIS services were available, the computer would easily crash. So we thought, why, we don't put our services on more than one computer? So when the last request goes to 192.168.**.252:8070, we can get the next request to 192.168.**.253:8071 so that we can reduce the pressure on our servers.

Now there is a problem, how can user request send to different server? This time, you need nginx.

Now let me introduce the Web service of. NET published on Nginx.

Nginx is an unpacking package, we only need to unzip the server on Nginx, modify the configuration file, Nginx installed.

Installation and configuration of Nginx

Nginx unzip to the root directory of the C drive below:

We can see the file directory under Nginx, here we want to modify the nginx.conf file under the Conf folder:

Probably explain:

Where the file is like this:

#user nobody;worker_processes 1; #工作进程的个数, multiple #error_log Logs/error.log can be configured, #error_log logs/error.log notice; #error_ Log logs/error.log info; #pid logs/nginx.pid;events {worker_connections, #单个进程最大连接数 (maximum number of connections = number of connections * processes)} #设定htt P server, which uses its reverse proxy function to provide load Balancer support for HTTP {include mime.types; #文件扩展名与文件类型映射表 default_type Application/octet-stream; #默认文件类 Type #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; #开启高效文件传输模式, the sendfile directive specifies whether Nginx calls the Sendfile function to output files, is set to on for normal applications, and if it is used for downloading applications such as disk IO heavy load applications, it can be switched off to balance disk and network i/ o processing speed, reducing the load on the system.    Note: If the picture does not appear normal, change this to off.    #tcp_nopush on;    #keepalive_timeout 0; Keepalive_timeout 65; #长连接超时时间, the unit is in seconds gzip on; #启用Gizp压缩 # server cluster upstream netitcast.com {#服务器集群名字 server 127.0.0.1:8030 weight=1; #服务器配 Weight is the meaning of weight, the larger the weight, the greater the probability of distribution.Server 127.0.0.1:8040 weight=1;}        #当前的Nginx的配置 server {Listen 8090; #监听80端口 can be changed to a different port server_name localhost;############# #当前服务的域名        #charset Koi8-r;        #access_log Logs/host.access.log Main;        #location/{# root HTML;        # index index.html index.htm;            #}location/{Proxy_pass http://netitcast.com;        Proxy_redirect default; } #location ~ \.          (JPG|PNG|JPEG|BMP|GIF|SWF|CSS) $ #{# expires 30d;        # root/nginx-1.4.7; #root: # break;        #} #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 scriptsTo 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; #    }    #}}

Where to modify:

#服务器的集群    upstream  netitcast.com {  #服务器集群名字  server    127.0.0.1:8030 weight=1; #服务器配置   Weight is the meaning of weight, the larger the weight, the greater the probability of distribution. Server    127.0.0.1:8040 weight=1;} #当前的Nginx的配置    Server {        listen       8090; #监听80端口, can be changed to another port        server_name  localhost;############## The domain name of the current service        #charset koi8-r;        #access_log  logs/host.access.log  main;        #location/{        #    root   html;        #    Index  index.html index.htm;        #}location/{            proxy_pass http://netitcast.com;            Proxy_redirect default;        }

We can see the name of the server cluster:

Server Ip:port

We will publish our project on that server's IP and port, and we can write the IP and port number here. The weight in the back is weighted, that is, if two servers are 1, the request is 1:1, the first request is accessed on port 8030, and the second request is accessed on port 8040.

server{Listen 8090} is the port number of the Nginx listener, which means that we can access the service in our server cluster only by accessing the IP and port number of the Nginx server.

The principle of Nginx:

Nginx configuration, in the next blog, we publish our Web services to our IIS.

Reference Blog: http://blog.csdn.net/zhanghan18333611647/article/details/50282951

The above describes the Nginx + IIS + Web front-end (Spring MVC)-load balancing (a), including aspects of the content, I hope to be interested in PHP tutorial 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.