【问题标题】:NGINX load balencerNGINX 负载均衡器
【发布时间】:2012-07-11 11:38:41
【问题描述】:

我们已经设置了 nginx 服务器,并尝试与其他 2 台服务器进行负载平衡。

设置是:一台主服务器(代理服务器)和另外两台服务器(服务请求)

我们有一组 .css、.js 和 .php 文件。我们希望主服务器提供所有静态文件,如 .css、.js 和图像文件,并且仅针对 .php 请求,我们希望以负载平衡的方式将请求转发到 2 个服务服务器之间。

请指导我如何做到这一点。

【问题讨论】:

    标签: nginx load load-balancing


    【解决方案1】:
    upstream backends {
        server backend1.example.com;
        server backend2.example.com;
    }
    
    server {
    
        location / {
            # your static configuration
            root /path/to/static/files;
        }
    
        location ~ \.php$ {
            # your proxy configuration
            proxy_pass http://backends;
        }
    
    }
    

    文档是一个很好的起点。

    【讨论】:

      【解决方案2】:

      你可以试试具体的

      location /abcd/admin {
      
       server backend1.example.com
      
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-04-28
        • 2020-08-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-12-07
        • 1970-01-01
        • 2023-04-09
        相关资源
        最近更新 更多