【问题标题】:Nginx Configuration - Upstream - Backup ServerNginx 配置 - 上游 - 备份服务器
【发布时间】:2017-03-16 07:36:22
【问题描述】:

我的上游有问题,我想知道我的 nginx 配置有什么问题:

upstream backends {
server 127.0.0.1:80;
server 188.200.200.200 backup;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html index.php;

    server_name localhost;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ =404;
        proxy_read_timeout 150;
        proxy_pass http://backends;
        proxy_set_header Host $host;
        proxy_next_upstream error timeout http_500 http_502 http_503 http_504;
 }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000


location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_read_timeout 150;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            fastcgi_buffer_size 128k;
            fastcgi_buffers 4 256k;
            fastcgi_busy_buffers_size 256k;

    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
            deny all;
    }

 location ~* \.      (jpg|jpeg|gif|png|css|js|ico|xml|woff|ttf|otf|svg|woff2|eot)$ {
     access_log        off;
     log_not_found     off;
     expires           30d;
 }

它在日志中给出这条消息: connect() 在连接到上游时失败(111:连接被拒绝),客户端:xx.xx.xx.xx,服务器:localhost,请求:“GET / HTTP/1.1”,上游:“fastcgi://127.0.0.1: 9000"

有人可以帮助我吗?

提前致谢

【问题讨论】:

    标签: php nginx backend


    【解决方案1】:

    您似乎正在请求一个.php 文件,该文件由第二个位置块提供服务。在这个块中,nginx 尝试按照fastcgi_pass 127.0.0.1:9000;-directive 连接到127.0.0.1:9000。但是这个地址似乎没有运行 FastCGI 守护进程。

    如果您请求/ 并且没有来自index 指令的索引文件,则可能会发生同样的情况。最后一个条目 (index.php) 也激活了第二个位置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-12-27
      • 2018-01-24
      • 2017-05-12
      • 1970-01-01
      • 2022-01-24
      • 2011-08-13
      • 2021-06-14
      相关资源
      最近更新 更多