Home  >  Q&A  >  body text

In addition to using proxy_pass for load balancing, is there any other way for nginx?

Someone asked me this during the previous interview. . .

仅有的幸福仅有的幸福2713 days ago608

reply all(1)I'll reply

  • 漂亮男人

    漂亮男人2017-05-16 17:09:31

    For example, PHP load balancing does not require a reverse proxy. Direct fastcgi_pass to multiple php-fpm can also be used for load balancing.

    Specific configuration:

    upstream myapp {
        server 192.168.20.1:9000; # PHP-FPM 1
        server 192.168.20.2:9000; # PHP-FPM 2
        ......
    }
    server {
        listen 80;
        location ~ \.php$ {
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME /phpfiles$fastcgi_script_name;
            fastcgi_pass myapp;
        }
    }

    reply
    0
  • Cancelreply