【问题标题】:Nginx:[error] 2147#2147: *1 connect() failed (111: Connection refused) while connecting to upstream,Nginx:[error] 2147#2147: *1 connect() failed (111: Connection refused) 连接到上游时,
【发布时间】:2020-12-08 16:00:05
【问题描述】:

我的 nginx 配置有问题,我不知道我做错了什么,但我的服务器给出了 502 bad gateway 我正在添加配置

   server {
    listen 80;
    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;
    server_name 188.166.254.137;

    location / {
            proxy_pass http://localhost:3000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    }

    location ~ /\.ht {
            deny all;
    }
 }

请告诉我我哪里做错了

【问题讨论】:

  • 你检查过 php-fpm 正在运行吗?套接字存在吗?
  • php-fpm 正在运行,它的状态是活动流量 0 请求/发送

标签: nginx nginx-reverse-proxy nginx-config


【解决方案1】:

谢谢... 我已经解决了我的问题

location / {
           # proxy_pass http://localhost:3000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            try_files $uri $uri/ =404;
    }

评论proxy_pass http://localhost:3000

会工作,因为端口 3000 上没有正在进行的进程

【讨论】:

    猜你喜欢
    • 2017-07-30
    • 1970-01-01
    • 2016-01-21
    • 1970-01-01
    • 1970-01-01
    • 2019-02-24
    • 2022-01-18
    • 2017-07-08
    • 1970-01-01
    相关资源
    最近更新 更多