2

I run a NGINX-PHP7-COMPOSER image that works well but when using Slim Framework I had to change Nginx's default config to make the URL rewrites work.

And now it show this error in the logs:

2017-01-21 14:38:34,357 INFO success: php-fpm7 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

2017-01-21 14:38:34,359 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

2017/01/21 14:38:37 [error] 15#15: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.18.0.1, server: auth-api, request: "GET /hello HTTP/1.1", upstream: "fastcgi://172.18.0.6:9000", host: "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, like Gecko) Chrome/55.0.2883.95 Safari/537.36"

The config file I mounted is loaded (I checked the bash with nginx -T):

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;
    }
}

My Dockerfile (just the image i am loading from the repository):

FROM richarvey/nginx-php-fpm

And my 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"

I pinged the IP with telnet...

telnet ping

Do you have any idea of what is going wrong?

  • The third entry in your log at 14:38:37 tells you what the problem is - Nginx can't connect to the back end server. What additional help do you need? You haven't clearly said what your problem is, what the symptoms are, or what help you need. You just to configure Nginx to talk to the upstream server properly, but we can't help with that as you haven't given us any details. – Tim Jan 22 '17 at 2:31
  • @Tim what details do you need, I'm happy to dig in and provide them? – Lazhar Jan 22 '17 at 2:35
  • You need to work out the address of your back end application and put that into the Nginx config file. I don't know any Docker so you're going to have to work that part out yourself. I can tell you I use this "fastcgi_pass 127.0.0.1:9001;" which matches one of the ports in your docket config. – Tim Jan 22 '17 at 2:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.