D
D
Dragonzcxv2021-08-02 23:17:48
PHP
Dragonzcxv, 2021-08-02 23:17:48

Docker: nginx + php-fpm, 502 error when changing port for php-fpm. How to fix?

Hello! When changing the port of php-fpm from the standard 9000 to some other (40001 in my case), nginx starts to issue a 502 error. I can not understand what it is connected with, but I really want to understand. Open my eyes please

docker-compose.yml:

version: '3'
services: 
    nginx:
        image: nginx:latest
        ports:
            - "8000:80"
        volumes: 
            - ./hosts:/etc/nginx/conf.d
            - ./www/backend:/var/www
            - ./logs:/var/log/nginx
        depends_on:
            - backend
    backend:
        build: 
            context: images/backend
            dockerfile: dockerfile
        depends_on:
            - mysql
        ports: 
            - "40001:9000"
        volumes: 
            - ./www/backend:/var/www


nginx.conf:
server {
    index index.php index.html;
    server_name backend;
    error_log  /var/log/nginx/backend.error.log;
    access_log /var/log/nginx/backend.access.log;
    root /var/www;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass backend:40001;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2021-08-02
@Dragonzcxv

You map another port to the outside - but inside it remains 9000.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question