Docker、Nginx 和 PHP7:连接到上游时出现错误 111 连接被拒绝

Docker、Nginx 和 PHP7:连接到上游时出现错误 111 连接被拒绝

我运行了一个运行良好的 NGINX-PHP7-COMPOSER 图像,但是当使用 Slim Framework 时,我必须更改 Nginx 的默认配置才能使 URL 重写正常工作。

现在日志中显示此错误:

2017-01-21 14:38:34,357 INFO 成功:php-fpm7 进入运行状态,进程已运行超过 1 秒(startsecs)

2017-01-21 14:38:34,359 INFO 成功:nginx 进入运行状态,进程已停留超过 1 秒(startsecs)

2017/01/21 14:38:37 [错误] 15#15:*1 connect() 连接到上游时失败(111:连接被拒绝),客户端:172.18.0.1,服务器:auth-api,请求:“GET /hello HTTP/1.1”,上游:“fastcgi://172.18.0.6:9000”,主机:“localhost:9100”

172.18.0.1 - - [21/Jan/2017:14:38:37 +0000] "GET /hello HTTP/1.1" 502 537 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML,如 Gecko) Chrome/55.0.2883.95 Safari/537.36"

我挂载的配置文件已加载(我用 nginx -T 检查了 bash):

server {
    listen 80;
    server_name auth-api;
    index index.php;
    root /var/www/html;

    location / {
        try_files $uri /index.php$is_args$args;
    }

    location ~ \.php {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_index index.php;
        fastcgi_pass auth-api:9000;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

我的 Dockerfile(只是我从存储库加载的图像):

FROM richarvey/nginx-php-fpm

还有我的docker-compose.yml:

version: '2'

services:

#############
## MARIADB ##
#############

    mariadb:
        image: mariadb
        restart: always
        volumes:
            - "./log/mariadb:/var/log/mysql:rw"
            - "./data/mariadb:/var/lib/mysql:rw"
        environment:
            - "MYSQL_ROOT_PASSWORD=pass"
        ports:
            - "3306:3306"

##############
## FRONTEND ##
##############

    frontend:
        image: skiychan/nginx-php7:latest
        volumes:
            - ./services/frontend/src:/data/www
        links:
            - mariadb:mysql
        ports:
            - "9001:80"

##############
## AUTH API ##
##############

    auth-api:
        build: ./services/api/auth/
        volumes:
            - ./services/api/auth/code/:/var/www/html
            - ./services/api/auth/:/etc/nginx/sites-available/
        links:
            - mariadb:mysql
        ports:
            - "9100:80"
            - "9000:9000"

我使用 telnet ping 了 IP...

远程登录

你知道出了什么问题吗?

相关内容