Use Nginx load balancer to build high performance. Netweb Application II

Source: Internet
Author: User

One, download Nginx deployment package

To the Nginx website to download an NGINX deployment package under the Windows platform, I am currently downloading a nginx-1.6.2 version.

Second, the command to start the service
Start: Start Nginx.exe
Stop: Nginx-s stop

Reload: Nginx-s Reload

Iii. Construction of examples
Preferred: We are going to deploy our well-done Web application on our IIS, deploy it to different machines, set the corresponding IP and port number, because I am simulating the effect on this machine, so I deployed 2 Web applications on this computer. The first Web application was deployed on the localhost:8011 port, the second application was deployed as a localhost:8012 port, and in order to see the demo, we made a tag inside the WebForm1.aspx page labeled: The pages of the Web application, the actual deployment of the system, we do not need to do this is to deploy one of our Web applications on the server above the 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 Nginx Service

(2) Modify the Nginx configuration, specific configuration instructions, we set the parameters in the department description, and then verify that the service started normally.

(3) Access address http://localhost:8010/WebForm1.aspx observation results

(4) So we can simulate the load-balancing effect, OK

Iv. Other Notes

(1) Configure the domain name access: First we want to add the domain name setting in Nginx, next we want to set the 127.0.0.1 map to the domain name in the native machine

So we can access this: http://huangxiang:8010/WebForm1.aspx

(2) Configure the number of processes that Ngnix starts, and we can focus on the number of process changes in the process

Five, parameter setting

[JavaScript]View Plaincopyprint?
  1. #定义Nginx运行的用户和用户组
  2. #user nobody;
  3. #Nginx进程数, the recommendation is consistent with the CPU's total kernel
  4. Worker_processes 2;
  5. #error_log Logs/error.log;
  6. #error_log Logs/error.log Notice;
  7. #error_log Logs/error.log Info;
  8. #pid Logs/nginx.pid;
  9. Events {
  10. #定义单个进程的最大连接数 (the actual maximum number of connections is divided by 2)
  11. Worker_connections 1024;
  12. }
  13. #定义http服务器
  14. HTTP {
  15. Include Mime.types; #定义文件扩展名和文件类型映射表
  16. Default_type Application/octet-stream;
  17. #log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
  18. # ' $status $body _bytes_sent ' $http _referer '
  19. # ' "$http _user_agent" "$http _x_forwarded_for" ';
  20. #access_log Logs/access.log Main;
  21. Sendfile on;
  22. #tcp_nopush on;
  23. #keepalive_timeout 0;
  24. Keepalive_timeout 65;
  25. #gzip on;
  26. #服务器的集群
  27. Upstream huangxiang.com {#服务器集群名字
  28. #server 172.16.21.13:8081 weight=1, #服务器配置 weight is the weight, the larger the weight, the greater the probability of distribution.
  29. #server 192.168.1.186:8081 weight=1;
  30. #server 172.16.1.14:8081 weight=2;
  31. #server 172.16.1.15:8081 weight=1;
  32. #server 172.16.1.15:80 weight=1;
  33. Server 127.0.0.1:8011 weight=1;
  34. Server 127.0.0.1:8012 weight=2;
  35. }
  36. #虚拟机主机配置
  37. server {
  38. Listen 8010; #端口号
  39. server_name localhost huangxiang.com; #域名可以有多个, multiple separated by spaces
  40. #charset Koi8-r;
  41. #access_log Logs/host.access.log Main;
  42. #location/{
  43. # root HTML;
  44. # index index.html index.htm;
  45. #}
  46. Location/{
  47. Proxy_pass http://huangxiang.com;
  48. Proxy_redirect default;
  49. }
  50. #error_page 404/404.html;
  51. # REDIRECT Server error pages to the static page/50x.html
  52. #
  53. Error_page 502 503 504/50x.html;
  54. Location =/50x.html {
  55. root HTML;
  56. }
  57. # Proxy The PHP scripts to Apache listening on 127.0.0.1:80
  58. #
  59. #location ~ \.php$ {
  60. # Proxy_pass http://127.0.0.1;
  61. #}
  62. # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  63. #
  64. #location ~ \.php$ {
  65. # root HTML;
  66. # Fastcgi_pass 127.0.0.1:9000;
  67. # Fastcgi_index index.php;
  68. # Fastcgi_param Script_filename/scripts$fastcgi_script_name;
  69. # include Fastcgi_params;
  70. #}
  71. # Deny access to. htaccess files, if Apache ' s document Root
  72. # concurs with Nginx ' s one
  73. #
  74. #location ~/\.ht {
  75. # Deny All;
  76. #}
  77. }
  78. # Another virtual host using mix of ip-, name-, and port-based configuration
  79. #
  80. #server {
  81. # Listen 8000;
  82. # Listen somename:8080;
  83. # server_name somename alias Another.alias;
  84. # location/{
  85. # root HTML;
  86. # index index.html index.htm;
  87. #    }
  88. #}
  89. # HTTPS Server
  90. #
  91. #server {
  92. # Listen 443 SSL;
  93. # server_name localhost;
  94. # ssl_certificate Cert.pem;
  95. # Ssl_certificate_key Cert.key;
  96. # Ssl_session_cache shared:ssl:1m;
  97. # ssl_session_timeout 5m;
  98. # ssl_ciphers high:!anull:! MD5;
  99. # ssl_prefer_server_ciphers on;
  100. # location/{
  101. # root HTML;
  102. # index index.html index.htm;
  103. #    }
  104. #}
  105. }



Use Nginx load balancer to build high performance. Netweb Application II

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.