nginx does not display index php

4

So guys, I think it's some configuration on the server that is not displaying the error page, I am running a docker-compose that "uploads" a container php, mysql, and nginx , however, when accessing localhost I get the following error:

- 403 Forbidden

Follow the nginx configuration file:

server {
    listen 80;
    index index.php index.html;
    server_name localhost;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /code;

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

And the docker-compose to take the curiosity:

version: '2'
services:
    web:
        image: nginx:latest
        ports:
            - "80:80"
        volumes:
            - ./code/public_html:/code
            - ./site.conf:/etc/nginx/conf.d/default.conf
        links:
            - php
    php:
        image: php7-custom-conf
        volumes:
            - ./code/public_html:/code
        links:
            - db
    db:
        image: mysql:5.7
        volumes:
        - "./.data/db:/var/lib/mysql"
        restart: always
        ports:
            - "3306:3306"
        environment:
         MYSQL_ROOT_PASSWORD: dbrootpass
         MYSQL_DATABASE: dbname
         MYSQL_USER: dbuser
         MYSQL_PASSWORD: dbpass

All the help is welcome, it's the end of the semester and I can not really see the error, thanks in advance.

    
asked by anonymous 01.11.2017 / 03:59

2 answers

1

Apparently it was a directory permission error, I managed to work around the problem using chmod 0755 ./code/public_html apparently the linux access settings allowed only my user, and with this command I release read and write to the owner of the file, users the same group, and other users.

Sources: link

link

    
02.11.2017 / 00:08
1

Hello, Uses another nginx image from docker, these new images are different settings, would have to look in the documentation. I use it that way and it works.

nginx:
    image: tutum/nginx
    ports:
        - "80:80"
    links:
        - phpfpm
    volumes:
        - ./nginx/default:/etc/nginx/sites-available/default
        - ./nginx/default:/etc/nginx/sites-enabled/default

        - ./logs/nginx-error.log:/var/log/nginx/error.log
        - ./logs/nginx-access.log:/var/log/nginx/access.log
phpfpm:
    image: php:fpm
    ports:
        - "9000:9000"
    volumes:
        - ./public:/usr/share/nginx/html
    
01.11.2017 / 10:24