windows 下设置nginx负载均衡
#user nobody;
worker_processes ; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections ;
} 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 ;
keepalive_timeout ; #gzip on; upstream mysvr {
#weigth参数表示权值,权值越高被分配到的几率越大
#.down 表示单前的server暂时不参与负载
#.weight 默认为1.weight越大,负载的权重就越大。
#.backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。所以这台机器压力会最轻。
#server 192.168.1.116 down;
#server 192.168.1.116 backup;
server 192.168.1.128: weight=;
server 192.168.1.194: weight=;
} server {
listen ; #这里是外网公布的访问的端口
server_name 122.122.122.122; #这里是外网公布的访问的公网ip 、或是域名 #charset koi8-r; #access_log logs/host.access.log main; location / {
proxy_pass http://mysvr; #跟载均衡服务器的upstream对应 proxy_connect_timeout 5s; #这里代表其中一台服务器宕机之后把访问转向另外一台服务器
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#禁用缓存
proxy_buffering off;
} #error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:;
# 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 ;
# listen somename:;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 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相关命令:
1) 启动Nginx:start nginx
2) 停止Nginx:nginx -s stop
3) 修改配置后重启:nginx -s reload
windows 下设置nginx负载均衡的更多相关文章
- windows下搭建nginx负载均衡
学习笔记,第一次记录避免忘记 首先介绍一下本地环境是windows2008 R2-64位. 1. 到nginx官网上下载最新稳定版的安装包,http://nginx.org/en/download. ...
- Windows下apache+tomcat负载均衡
Windows下apache+tomcat负载均衡 网上已经有很多的资料,但是很多都比较零碎,需要整合一起才能搭建出理想的负载均衡,正好前段时间搭建了windows与linux下的负载均衡,在此记录, ...
- Mac下配置Nginx负载均衡
1.首先在Mac下安装Nginx(可参考我的另一篇随笔http://www.cnblogs.com/malcolmfeng/p/6896703.html). 2.安装Tomcat,下载后,解压,bin ...
- linux下配置nginx负载均衡例子
准备2台虚拟机: 分别在两个虚拟机上安装tomcat,并在服务器A安装nginx,其中nginx端口设置为了 70. 服务器A的tomcat安装目录: 服务器B的tomcat安装目录: 服务器A的ng ...
- Nginx负载均衡搭建(Window与Linux)
windows上搭建nginx负载均衡 1.准备几台http服务器软件,这里选用一台apache一台tomcat apache(windows)下载链接:https://www.apachehaus. ...
- NGINX 负载均衡的理解
前言 NGINX是轻量级,也是当前比较流行的web服务器软件.体积小但是功能强大. 这里我按照自己的理解,记录下对NGINX负载均衡的认识.(加权均衡,最小连接) 这里参考了 [https://blo ...
- Nginx负载均衡策略的介绍与调优
工作中经常会用到nginx负载均衡这一块,下面对nginx负载均衡策略做个总结.本人在工作中最常用到的负载均衡策略是轮询策略. 在一般情况下,Web中间件最大的作用就是负责对请求进行分发,也就是我们常 ...
- Windows下使用Nginx+Tomact做负载均衡
前言 今天,王子与大家闲谈一下如何在Windows下使用Nginx+Tomcat做负载均衡的完整步骤,小伙伴们可以试着自己动手实践一下哦. 另外说明一点,本篇文章是纯实操文章,不涉及太多原理的解读,后 ...
- Windows实战(1):Nginx代理设置及负载均衡配置
简言 以下配置实现功能: 反向代理 通过轮询的方式实现nginx负载均衡 直接看以下配置文件: #user nobody; worker_processes 1; #error_log logs/er ...
随机推荐
- 无线LoRa智能远传水表
1.1 主流程 无线远传智能预付费水表是基于瑞萨R7F0C002芯片开发的一款水表,该款水表包含了电子计数.远程充值.远程开关阀.费控.欠费提醒等功能. 水表通信采用LoRa无线模式,芯片采用SX12 ...
- java使用正则表达式
package com.regexp; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Tes ...
- DC-学习
1.DC概论一:setup time, hold time之一 http://www.blogbus.com/bb2hh-logs/20463915.html 2.DC概论二:fanout, skew ...
- pd.concat()命令
这个生成dataframe函数还是蛮有意思的.
- 上海高校金马五校赛 F题:1 + 2 = 3?
链接:https://www.nowcoder.com/acm/contest/91/F来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语言26214 ...
- Unity之Application.runInBackground = true
默认是False, 设置 Application.runInBackground = true; 则 void OnApplicationPause(bool pause) 不再起作用
- JMeter 连接MySQL
第一步:添加JDBC 驱动 第二步:在线程组 下面添加一个“JDBC Connection Configuration” 第三步:在“线程组”,在下面添加一个“JDBC request”
- ActiveMQ之HelloWorld
JMS实现JMS接口的消息中间件 Provider:生产者 Consumer:消费者 PTP:Point to Point:点对点的消息模型 Pub/Sub:Publish/Subscribe:发布订 ...
- git删除提交历史
精准入口==>官方文档 Q:我们在提交代码时,把密码或者敏感信息也提交了,怎么办? A:“在本地删除密码或敏感信息后,再push到远程仓库” Q:"但这样删除后,在仓库的commit历 ...
- mysql中的 随机字符串的生成
方法1. SELECT SUBSTRING(MD5(RAND()),FLOOR(RAND()*26)+1,6) AS rand_str; 上诉示例产生的是:6位长度的随机字符串. 函数解释: rand ...