只简单说一下upstream的配置,如何进行负载均衡后续还需要多了解

1.另准备一个配置文件命名为nginx_test.conf

为了不污染原有的nginx.conf,提前复制一份配置文件做试验,然后启动nginx时加载nginx_test.conf

启动命令:

[root@localhost conf]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx_test.conf

-c参数表示加载指定的配置文件,后面跟的是文件路径

2.在http模块下添加upstream配置

    upstream tomcat
{
server localhost:; # 对应server下location中添加的 proxy_pass
}
upstream ApprPhD
{
server 192.168.0.1XX:;
}
server {
listen ;
server_name hanmk.com;
location / {
root /tmp/data/;
autoindex on;
}
}
server {
listen default_server;
server_name demo.com ;
#charset koi8-r; #access_log logs/host.access.log main;
# location / {
# root html;
# index index.html index.htm;
# } location / {
proxy_pass http://tomcat; # 对应upstream为tomcat,访问本地tomcat
} #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;
#} location /jenkins {
proxy_pass http://tomcat; #对应upstream为tomcat,访问本地tomcat中部署的jenkins proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; #获取真实ip
proxy_connect_timeout ;
proxy_send_timeout ;
proxy_read_timeout ;
proxy_buffer_size 4k;
proxy_buffers 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;#获取代理者的真实ip
proxy_redirect off;
}
location /ApprPhD {
proxy_pass http://ApprPhD; # 对应upstream为ApprPhD,访问1XX服务器部署的ApprPhd
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; #获取真实ip
proxy_set_header REMOTE-HOST $remote_addr;
proxy_connect_timeout ;
proxy_send_timeout ;
proxy_read_timeout ;
proxy_buffer_size 4k;
proxy_buffers 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;#获取代理者的真实ip
proxy_redirect off;
} }

初探nginx负载均衡配置的更多相关文章

  1. Tomcat集群,Nginx集群,Tomcat+Nginx 负载均衡配置,Tomcat+Nginx集群

    Tomcat集群,Nginx集群,Tomcat+Nginx 负载均衡配置,Tomcat+Nginx集群 >>>>>>>>>>>> ...

  2. Nginx负载均衡配置简单配置方法

    http://www.jb51.net/article/121235.htm Nginx作为负载均衡服务器,用户请求先到达nginx,再由nginx根据负载配置将请求转发至不同的Web服务器.下面通过 ...

  3. nginx高性能WEB服务器系列之六--nginx负载均衡配置+健康检查

    nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...

  4. Mall电商项目总结(二)——nginx负载均衡配置和策略

    1. nginx配置文件 用户在浏览器上输入,http://www.xwld.site/ 实际上是在访问服务器80端口,nginx 监听80端口,将用户的请求转发到8080和9080端口 . upst ...

  5. Tomcat服务部署与Nginx负载均衡配置

    一.中间键产品介绍 目前来说IBM的WebSphere,Oracle的Weblogic占据了市场上java语言Web站点的部分份额,该两种软件都是商业化的软件,由于性能优越,可靠性高等优点应用于大型互 ...

  6. Docker 安装 Nginx 负载均衡配置

    Docker 安装 # 1)安装依赖包 yum install -y yum-utils device-mapper-persistent-data lvm2 # 2)添加Docker软件包源(否则d ...

  7. Nginx负载均衡配置实例详解

    负载均衡是我们大流量网站要做的一个东西,下面我来给大家介绍在Nginx服务器上进行负载均衡配置方法,希望对有需要的同学有所帮助哦. 负载均衡 先来简单了解一下什么是负载均衡,单从字面上的意思来理解就可 ...

  8. Nginx负载均衡配置实例详解(转)

    负载均衡是我们大流量网站要做的一个东西,下面我来给大家介绍在Nginx服务器上进行负载均衡配置方法,希望对有需要的同学有所帮助哦. 负载均衡 先来简单了解一下什么是负载均衡,单从字面上的意思来理解就可 ...

  9. 如何配置nginx负载均衡配置(轮询,权重,ip绑定)

    集群是为了解决单节点无法服务高并发的情况,在集群中nginx是如何分配将来自客户端的请求 转发给服务器的 负载均衡可以提高网站的吞吐量(接受和响应),减轻单台服务器的压力 负载均衡提供了三种策略:轮询 ...

随机推荐

  1. indexOf()/equals/contains

    indexOf():对大小写敏感定义:返回某个指定字符串值在字符串中首次出现位置用法:返回字符中indexof(string)中字串string在父串中首次出现的位置,从0开始!没有返回-1:方便判断 ...

  2. nginx按日期分割日志

    #!/bin/bash # Program:chenglee # Auto cut nginx log script. LOGS_PATH="/usr/local/nginx1.13/log ...

  3. Codeforces 711D Directed Roads - 组合数学

    ZS the Coder and Chris the Baboon has explored Udayland for quite some time. They realize that it co ...

  4. pillow生成验证码

    1.结果 2.安装pillow cmd里进入python,pip install pillow,需要等一段时间 3.代码 from PIL import Image, ImageDraw, Image ...

  5. Ping 不通的原因分析

    背景 简介 ping是常用的网络管理命令,ping也属于一个通信协议,是TCP/IP协议的一部分,适用于windows和linux以及unix 根据reply用来检查网络是否通畅&网络连接的速 ...

  6. bzoj1566: [NOI2009]管道取珠 DP

    题目链接 https://www.lydsy.com/JudgeOnline/problem.php?id=1566 思路 n个球,第i个球颜色为ai,对于颜色j,对答案的贡献为颜色为j的球的个数的平 ...

  7. HDU 1392 Surround the Trees(凸包)题解

    题意:给一堆二维的点,问你最少用多少距离能把这些点都围起来 思路: 凸包: 我们先找到所有点中最左下角的点p1,这个点绝对在凸包上.接下来对剩余点按照相对p1的角度升序排序,角度一样按距离升序排序.因 ...

  8. 程序重启RocketMQ消息重复消费

    最近在调试RocketMQ消息发送与消费的Demo时,发现一个问题:只要重启程序,RocketMQ消息就会重复消费. 那么这是什么原因导致的,又该如何解决呢? 经过一番排查,发现程序使用的Rocket ...

  9. 查看kubernets上的image信息

    # 查看pods所使用的image kubectl describe pods $podsname -n $namespace #获取containers.$containername.image i ...

  10. Transaction2

    5. 事务状态 TransactionInformation 上面讲解过事务分为本地事务与分布式事务,而Transaction类的TransactionInformation是事务状态的记录,它可以跟 ...