2

I have an nginx reverse proxy container and also an nginx and a php-fpm one. I have no problem serving .html files but when I try to navigate to a .php I receive Error 404 Not Found.

This is the docker-compose.yml of nginx reverse proxy:

version: "2"

services:
  nginx-proxy:
    image: jwilder/nginx-proxy:alpine
    container_name: nginx-proxy
    ports:
      - "8080:80"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./vhost.d:/etc/nginx/vhost.d

networks:
  default:
    external:
      name: nginx-proxy-net

This is the docker-compose.yml of my website:

version: "2"

services:
  nginx:
    image: nginx:latest
    expose:
      - 80
    restart: always
    volumes:
      - ./html:/usr/share/nginx/html
    environment:
      - VIRTUAL_HOST=vhost.example.it
    container_name: vhost-html

  php:
    image: php:7-fpm
    expose:
      - 9000
    restart: always
    volumes:
      - ./html:/usr/share/nginx/html
    environment:
      - VIRTUAL_PROTO=fastcgi
      - VIRTUAL_ROOT=/usr/share/nginx/html
      - VIRTUAL_PORT=9000
      - VIRTUAL_HOST=vhost-php.local
    container_name: vhost-php

networks:
  default:
    external:
      name: nginx-proxy-net

Also I created a per-VIRTUAL_HOST configuration file inside vhost.d folder:

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass vhost-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;
}

Do you have any idea on how to fix this error?

0

You must log in to answer this question.