Nginx配置upstream实现负载均衡

  • A+
所属分类:运维教程

如果Nginx没有仅仅只能代理一台服务器的话,那它也不可能像今天这么火,Nginx可以配置代理多台服务器,当一台服务器宕机之后,仍能保持系统可用。具体配置过程如下:

  • 在http节点下面,添加upstream的节点。
  1. upstream birdteam {
  2. server 192.168.18.251;
  3. server 192.168.18.252;
  4. }
  • 将server节点下的location节点中的proxy_pass配置为http://+upstream名称,如http://birdteam。
  1. location / {
  2. proxy_pass http://birdteam;
  3. }
  • 现在负载均衡就初步完成了。upstream会按照轮询方式进行负载,每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器宕掉了,可以自动剔除。虽然这种方式简便、成本低廉。但缺点是:可靠性低和负载分配不均衡。适用图片服务器集群和纯静态页面服务器集群。
  • 问答中心
  • 微信小程序扫一扫
  • weinxin
  • 微信公众
  • 微信公众号扫一扫
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:10   其中:访客  10   博主  0

    • avatar his response

      so much great information on here, : D.

      • avatar web links

        I appreciate, cause I found just what I was looking for. You have ended my 4 day long hunt! God Bless you man. Have a great day. Bye

        • avatar erjilo pterin

          You have mentioned very interesting points! ps nice website.

          • avatar continue reading this

            An interesting discussion is worth comment. I think that you should write more on this topic, it might not be a taboo subject but generally people are not enough to speak on such topics. To the next. Cheers

            • I have recently started a site, the info you provide on this web site has helped me greatly. Thanks for all of your time & work.

              • avatar i loved this

                I haven’t checked in here for a while since I thought it was getting boring, but the last few posts are great quality so I guess I’ll add you back to my everyday bloglist. You deserve it my friend :)

                • avatar smoretraiolit

                  A person essentially help to make seriously posts I would state. This is the first time I frequented your web page and thus far? I amazed with the research you made to make this particular publish extraordinary. Wonderful job!

                  • avatar smore traiolit

                    Magnificent beat ! I wish to apprentice while you amend your site, how can i subscribe for a weblog web site? The account helped me a appropriate deal. I had been a little bit acquainted of this your broadcast offered shiny clear idea

                    • avatar Credit Card Fraud

                      Virtually all of the things you assert happens to be supprisingly accurate and that makes me ponder why I hadn’t looked at this with this light previously. This piece truly did turn the light on for me as far as this particular subject matter goes. Nonetheless there is actually 1 issue I am not too comfortable with and while I attempt to reconcile that with the actual central idea of the position, permit me see what all the rest of your visitors have to say.Well done.

                      • avatar Cody Bosma

                        Hi, i think that i saw you visited my blog so i came to “return the favor”.I’m attempting to find things to enhance my web site!I suppose its ok to use a few of your ideas!!