使用Nginx负载均衡搭建高性能.NETweb应用程序二
来源:互联网 发布:unity3d 显示3d模型 编辑:程序博客网 时间:2024/05/18 06:27
在文章《使用Nginx负载均衡搭建高性能.NETweb应用程序一》中,让我们对Nginx有了一个初步认识,下面我们将在windows平台下面使用Nginx演示集群部署我们的web应用。
到Nginx官网去下载一个windows平台下面的Nginx部署包,目前我下载的是一个nginx-1.6.2版本的。
启动:start nginx.exe
停止:nginx -s stop
重新加载: nginx -s reload
三、实例搭建
首选:我们要在我们的iis上面把我们做好的web应用部署上去,部署到不同的机器上面,设置好对应的ip和端口号,因为我在本机模拟出效果,所以我就在本机的iis上面部署了2个web应用,第一个web应用部署在localhost:8011端口,第二个应用部署为localhost:8012端口,同时为了看到演示效果,我们把里面的WebForm1.aspx页面做了一个标记,里面标记为:第几个web应用程序的页面,实际我们部署系统,不需要这样做,就是把我们的一个web应用部署到不同机器上面的服务器上,下面所示。
web应用1地址:http://localhost:8011/WebForm1.aspx
web应用2地址:http://localhost:8012/WebForm1.aspx
(1)启动Nginx服务
(2)修改Nginx配置项,具体配置说明,我们在参数设置部门说明,然后验证服务是否正常启动。
(3)访问地址http://localhost:8010/WebForm1.aspx观察结果
(4)这样我们就可以模拟出负载均衡效果了,ok
四、其他说明
(1)配置域名访问:首先我们要在Nginx中添加域名设置,其次我们要在本机设置127.0.0.1映射为域名
这样我们就可以这样访问了:http://huangxiang:8010/WebForm1.aspx
(2)配置Ngnix启动的进程数量,我们可以在进程中关注其进程数量变化
五、参数设置
#定义Nginx运行的用户和用户组#user nobody;#Nginx进程数,建议和cpu总内核一致worker_processes 2;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events {#定义单个进程的最大连接数(实际最大连接数要除以2) worker_connections 1024;}#定义http服务器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; #服务器的集群 upstream huangxiang.com { #服务器集群名字 #server 172.16.21.13:8081 weight=1;#服务器配置 weight是权重的意思,权重越大,分配的概率越大。#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;}#虚拟机主机配置 server { listen 8010;#端口号 server_name localhost huangxiang.com;#域名可以有多个,多个用空格分开 #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 504 /50x.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 to .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_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; # } #}}
- 使用Nginx负载均衡搭建高性能.NETweb应用程序二
- 使用Nginx负载均衡搭建高性能.NETweb应用程序一
- Nginx+Tomcat搭建高性能负载均衡集群
- Nginx+Tomcat搭建高性能负载均衡集群
- linux上Nginx+Tomcat搭建高性能负载均衡
- Nginx+Tomcat搭建高性能负载均衡集群
- Nginx+Tomcat搭建高性能负载均衡集群
- Nginx+Tomcat搭建高性能负载均衡集群
- Nginx+Tomcat搭建高性能负载均衡集群
- Nginx+Tomcat搭建高性能负载均衡集群
- Nginx+Tomcat搭建高性能负载均衡集群
- Nginx+Tomcat搭建高性能负载均衡集群
- Nginx+Tomcat搭建高性能负载均衡集群
- Nginx+Tomcat搭建高性能负载均衡集群
- Nginx+Tomcat搭建高性能负载均衡集群
- Nginx+Tomcat搭建高性能负载均衡集群
- Nginx+Tomcat搭建高性能负载均衡集群
- Nginx+Tomcat搭建高性能负载均衡集群(Windows)
- java http
- 设计模式-命令模式
- ArcGIS教程:ArcGIS中图层添加投影及投影转换
- spring data elasticsearch的一个复杂查询条件
- JBoss Resteasy初探
- 使用Nginx负载均衡搭建高性能.NETweb应用程序二
- linux查看内核版本
- onvif开发系列之--------onvif 框架代码生成
- UIImage应用与内存管理
- 第十五周 项目1:读程序,单步调试
- Boosting(Adaboost+Haar-like人脸识别)
- flashlog.txt 不更新问题解决办法之一
- 什么是PERT网络分析?
- js 压缩