#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负载均衡的更多相关文章

  1. windows下搭建nginx负载均衡

    学习笔记,第一次记录避免忘记 首先介绍一下本地环境是windows2008 R2-64位. 1.  到nginx官网上下载最新稳定版的安装包,http://nginx.org/en/download. ...

  2. Windows下apache+tomcat负载均衡

    Windows下apache+tomcat负载均衡 网上已经有很多的资料,但是很多都比较零碎,需要整合一起才能搭建出理想的负载均衡,正好前段时间搭建了windows与linux下的负载均衡,在此记录, ...

  3. Mac下配置Nginx负载均衡

    1.首先在Mac下安装Nginx(可参考我的另一篇随笔http://www.cnblogs.com/malcolmfeng/p/6896703.html). 2.安装Tomcat,下载后,解压,bin ...

  4. linux下配置nginx负载均衡例子

    准备2台虚拟机: 分别在两个虚拟机上安装tomcat,并在服务器A安装nginx,其中nginx端口设置为了 70. 服务器A的tomcat安装目录: 服务器B的tomcat安装目录: 服务器A的ng ...

  5. Nginx负载均衡搭建(Window与Linux)

    windows上搭建nginx负载均衡 1.准备几台http服务器软件,这里选用一台apache一台tomcat apache(windows)下载链接:https://www.apachehaus. ...

  6. NGINX 负载均衡的理解

    前言 NGINX是轻量级,也是当前比较流行的web服务器软件.体积小但是功能强大. 这里我按照自己的理解,记录下对NGINX负载均衡的认识.(加权均衡,最小连接) 这里参考了 [https://blo ...

  7. Nginx负载均衡策略的介绍与调优

    工作中经常会用到nginx负载均衡这一块,下面对nginx负载均衡策略做个总结.本人在工作中最常用到的负载均衡策略是轮询策略. 在一般情况下,Web中间件最大的作用就是负责对请求进行分发,也就是我们常 ...

  8. Windows下使用Nginx+Tomact做负载均衡

    前言 今天,王子与大家闲谈一下如何在Windows下使用Nginx+Tomcat做负载均衡的完整步骤,小伙伴们可以试着自己动手实践一下哦. 另外说明一点,本篇文章是纯实操文章,不涉及太多原理的解读,后 ...

  9. Windows实战(1):Nginx代理设置及负载均衡配置

    简言 以下配置实现功能: 反向代理 通过轮询的方式实现nginx负载均衡 直接看以下配置文件: #user nobody; worker_processes 1; #error_log logs/er ...

随机推荐

  1. clearfix原理

    [clearfix原理] .clearfix:after { <----在类名为“clearfix”的元素内最后面加入内容: content: "."; <----内容 ...

  2. sqlite3调试

    [sqlite3调试] 1.adb shell 激活模拟器shell. 2.cd /data/data/com.xxx.xxx/databases 进入app 数据库目录. 3.ls 查看有哪些数据库 ...

  3. python网络编程之C/S架构介绍

    标签(空格分隔): c/s架构介绍 什么是C/S架构 C指的是client(客户端软件),S指的是Server(服务端软件),后续我们可以试着写个c/s软件实现服务器软件与客户端软件基于网络通信: 计 ...

  4. break

    public class b {   public static void main(String[] args) {  int i=0;  for(;i<=10;i++){   if (i&g ...

  5. Charles界面介绍及使用方法

    本随笔主要内容: 一.Charles界面介绍 二.Charles使用 1.会话(Repeat.Focus.Compare.黑白名单等) 2.模拟请求做mock,使用断点.Map或Rewrite 3.指 ...

  6. Could not load conf for core new_core 解決方法

    new_core: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Could not load ...

  7. STL::forward_list

    forward_list(c++11): 内部是一个单链表的实现:但是为了效率的考虑,故意没有 size 这个内置函数. Constructor 六种构造方式default; fill; range; ...

  8. DRF的视图和路由

    DRF的视图 APIView Django中写CBV的时候继承的是View,rest_framework继承的是APIView, urlpatterns = [ url(r'^book$', Book ...

  9. 关于set_output_delay与set_input_delay概念与用法

    一.  这两条约束语句都是针对板级延时而言的. 语句中必须的有是,时钟与port. 二.   set_input_delay 用于数据输入端口,调节数据输入与时钟输入到来的相位关系. 当FPGA外部送 ...

  10. PlayerPrefs Elite v1.4.3

    PlayerPrefs EliteProtect your game from cheating and modification for items, levels, highscores or s ...