502坏网关nginx无法连接

时间:2016-08-05 15:34:12

标签: php ubuntu nginx

连接到我的服务器时,我收到502坏网关。 Nginx错误日志显示以下日志:

[error] 5284#0: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 119.82.78.99, server: localhost, request: "GET /xxx..x..

我已经检查了他们运行的php-fpm和nginx进程,如下所示:

root      5279  0.0  0.0  85876  1340 ?        Ss   15:13   0:00 nginx: master process /usr/sbin/nginx
www-data  5282  0.0  0.1  86660  2300 ?        S    15:13   0:00 nginx: worker process
www-data  5283  0.0  0.1  86660  2300 ?        S    15:13   0:00 nginx: worker process
www-data  5284  0.0  0.1  86660  2556 ?        S    15:13   0:00 nginx: worker process
www-data  5285  0.0  0.1  86660  2300 ?        S    15:13   0:00 nginx: worker process
ubuntu    5772  0.0  0.0  10460   936 pts/1    S+   15:30   0:00 grep --color=auto ngin
root      4717  0.0  0.6 221468 13808 ?        Ss   14:59   0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
www-data  4720  0.0  0.2 221468  4480 ?        S    14:59   0:00 php-fpm: pool www
www-data  4721  0.0  0.2 221468  4480 ?        S    14:59   0:00 php-fpm: pool www
ubuntu    5770  0.0  0.0  10460   936 pts/1    S+   15:30   0:00 grep --color=auto php

Nginx配置文件

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
    worker_connections 2000;
    multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;



    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

添加/ etc / nginx / sites-available / default:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

    # Make site accessible from http://localhost/
    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_pass http://127.0.0.1:8080/;

            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;

            #proxy_set_header Host $host;
            #proxy_set_header X-Real-IP $remote_addr;
            #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }

你能否建议如何解决这个问题?

0 个答案:

没有答案