wodby / docker4php

Docker-based PHP stack
https://wodby.com/docker4php
MIT License
277 stars 44 forks source link

404 page not found #7

Closed dvoracek-jakub closed 5 years ago

dvoracek-jakub commented 5 years ago

Hello, I have this simple setup (shown below), but I ran into the following issue: When I visit http://php.def:8000 from my host, server returns only "404 page not found".

But if I run bash on the apache service container and visit (wget) http://localhost from there, the output of my /var/www/html/index.php file is returned as expected.

Bash @ apache container

$ cat /usr/local/apache2/conf/conf.d/vhost.conf
<VirtualHost *:80>
    DocumentRoot "/var/www/html"
    ServerName default

    Include conf/preset.conf

    <Location />
        Require all granted
    </Location>
    SetEnvIf Request_URI "^/\.healthz$" dontlog
    RedirectMatch 204 .healthz
</VirtualHost>

$ ls /var/www/html/
docker-compose.yml    docker-sync.yml     docker.mk      index.php        traefik.yml

$ wget -qO- http://localhost
OK, this is text from my index.php file

Host OS

Windows 10

Docker info output

Containers: 6
 Running: 5
 Paused: 0
 Stopped: 1
Images: 6
Server Version: 18.09.2
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9754871865f7fe2f4e74d43e2fc7ccd237edcbce
runc version: 09c8266bf2fcf9519a651b04ae54c967b9ab86ec
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.125-linuxkit
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.442GiB
Name: linuxkit-00155d011405
ID: GR3D:55ND:2TFB:DV2C:QEHF:NV66:JBWP:4ARE:HUKA:KDV6:YKZY:NERC
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 66
 Goroutines: 87
 System Time: 2019-06-23T11:05:29.693657Z
 EventsListeners: 2
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

Docker compose file

version: "3"

services:
  php:
    image: wodby/php:$PHP_TAG
    container_name: "${PROJECT_NAME}_php"
    environment:
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
#      DB_HOST: $DB_HOST
#      DB_USER: $DB_USER
#      DB_PASSWORD: $DB_PASSWORD
#      DB_NAME: $DB_NAME
      PHP_FPM_USER: wodby
      PHP_FPM_GROUP: wodby
    volumes:
      - ./:/var/www/html

  apache:
    image: wodby/apache:$APACHE_TAG
    container_name: "${PROJECT_NAME}_apache"
    depends_on:
      - php
    environment:
      APACHE_LOG_LEVEL: debug
      APACHE_BACKEND_HOST: php
      APACHE_VHOST_PRESET: php
      APACHE_DOCUMENT_ROOT: /var/www/html
    volumes:
      - ./:/var/www/html
# For macOS users (https://wodby.com/stacks/php/docs/local/docker-for-mac/)
#      - ./:/var/www/html:cached # User-guided caching
#      - docker-sync:/var/www/html # Docker-sync
    labels:
      - 'traefik.backend=${PROJECT_NAME}_apache'
      - 'traefik.port=80'
      - 'traefik.frontend.rule=Host:${PROJECT_BASE_URL}'

  mailhog:
    image: mailhog/mailhog
    container_name: "${PROJECT_NAME}_mailhog"
    labels:
      - 'traefik.backend=${PROJECT_NAME}_mailhog'
      - 'traefik.port=8025'
      - 'traefik.frontend.rule=Host:mailhog.${PROJECT_BASE_URL}'

  portainer:
    image: portainer/portainer
    container_name: "${PROJECT_NAME}_portainer"
    command: --no-auth -H unix:///var/run/docker.sock
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    labels:
      - 'traefik.backend=${PROJECT_NAME}_portainer'
      - 'traefik.port=9000'
      - 'traefik.frontend.rule=Host:portainer.${PROJECT_BASE_URL}'

  traefik:
    image: traefik
    container_name: "${PROJECT_NAME}_traefik"
    command: -c /dev/null --web --docker --logLevel=INFO
    ports:
      - '8000:80'
#      - '8080:8080' # Dashboard
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

Logs output

Attaching to my_php7_project_apache, my_php7_project_php, my_php7_project_portainer, my_php7_project_traefik, my_php7_project_mailhog
my_php7_project_apache | [Sun Jun 23 10:32:46.665338 2019] [ssl:info] [pid 1:tid 140150965349224] AH01887: Init: Initializing (virtual) servers for SSL
my_php7_project_apache | [Sun Jun 23 10:32:46.665383 2019] [ssl:info] [pid 1:tid 140150965349224] AH01876: mod_ssl/2.4.39 compiled against Server: Apache/2.4.39, Library: OpenSSL/1.1.1b
my_php7_project_apache | [Sun Jun 23 10:32:46.665414 2019] [http2:debug] [pid 1:tid 140150965349224] mod_http2.c(112): AH03089: initializing post config dry run
my_php7_project_apache | [Sun Jun 23 10:32:46.670329 2019] [ssl:warn] [pid 1:tid 140150965349224] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
my_php7_project_apache | [Sun Jun 23 10:32:46.670357 2019] [ssl:info] [pid 1:tid 140150965349224] AH01887: Init: Initializing (virtual) servers for SSL
my_php7_project_apache | [Sun Jun 23 10:32:46.670368 2019] [ssl:info] [pid 1:tid 140150965349224] AH01876: mod_ssl/2.4.39 compiled against Server: Apache/2.4.39, Library: OpenSSL/1.1.1b
my_php7_project_apache | [Sun Jun 23 10:32:46.670397 2019] [http2:info] [pid 1:tid 140150965349224] AH03090: mod_http2 (v1.14.1, feats=CHPRIO+SHA256+INVHD+DWINS, nghttp2 1.35.1), initializing...
my_php7_project_apache | [Sun Jun 23 10:32:46.670695 2019] [ldap:debug] [pid 1:tid 140150965349224] util_ldap.c(2988): AH01316: LDAP merging Shared Cache conf: shm=0x5574470161b0 rmm=0x557447016208 for VHOST: default
my_php7_project_apache | [Sun Jun 23 10:32:46.670911 2019] [ldap:info] [pid 1:tid 140150965349224] AH01318: APR LDAP: Built with OpenLDAP LDAP SDK
my_php7_project_apache | [Sun Jun 23 10:32:46.670943 2019] [ldap:info] [pid 1:tid 140150965349224] AH01319: LDAP: SSL support available
my_php7_project_apache | [Sun Jun 23 10:32:46.673186 2019] [proxy_http2:info] [pid 1:tid 140150965349224] AH03349: mod_proxy_http2 (v1.14.1, nghttp2 1.35.1), initializing...
my_php7_project_apache | [Sun Jun 23 10:32:46.675150 2019] [mpm_event:notice] [pid 1:tid 140150965349224] AH00489: Apache/2.4.39 (Unix) OpenSSL/1.1.1b configured -- resuming normal operations
my_php7_project_apache | [Sun Jun 23 10:32:46.675180 2019] [mpm_event:info] [pid 1:tid 140150965349224] AH00490: Server built: May 11 2019 02:36:43
my_php7_project_apache | [Sun Jun 23 10:32:46.675197 2019] [core:notice] [pid 1:tid 140150965349224] AH00094: Command line: 'httpd -D FOREGROUND'
my_php7_project_apache | [Sun Jun 23 10:32:46.675204 2019] [core:debug] [pid 1:tid 140150965349224] log.c(1571): AH02639: Using SO_REUSEPORT: yes (1)
my_php7_project_apache | [Sun Jun 23 10:32:46.676349 2019] [proxy:debug] [pid 22:tid 140150965349224] proxy_util.c(1934): AH00925: initializing worker proxy:reverse shared
my_php7_project_apache | [Sun Jun 23 10:32:46.676442 2019] [proxy:debug] [pid 22:tid 140150965349224] proxy_util.c(1991): AH00927: initializing worker proxy:reverse local
my_php7_project_apache | [Sun Jun 23 10:32:46.676588 2019] [proxy:debug] [pid 22:tid 140150965349224] proxy_util.c(2026): AH00930: initialized pool in child 22 for (*) min=0 max=61 smax=61
my_php7_project_apache | [Sun Jun 23 10:32:46.676721 2019] [proxy:debug] [pid 22:tid 140150965349224] proxy_util.c(1934): AH00925: initializing worker fcgi://php:9000/ shared
my_php7_project_apache | [Sun Jun 23 10:32:46.676838 2019] [proxy:debug] [pid 22:tid 140150965349224] proxy_util.c(1991): AH00927: initializing worker fcgi://php:9000/ local
my_php7_project_apache | [Sun Jun 23 10:32:46.676948 2019] [proxy:debug] [pid 22:tid 140150965349224] proxy_util.c(2026): AH00930: initialized pool in child 22 for (php) min=0 max=61 smax=61
my_php7_project_apache | [Sun Jun 23 10:32:46.677424 2019] [mpm_event:debug] [pid 22:tid 140150953499408] event.c(2314): AH02471: start_threads: Using epoll (wakeable)
my_php7_project_apache | [Sun Jun 23 10:32:46.677766 2019] [proxy:debug] [pid 27:tid 140150965349224] proxy_util.c(1934): AH00925: initializing worker proxy:reverse shared
my_php7_project_apache | [Sun Jun 23 10:32:46.677799 2019] [proxy:debug] [pid 27:tid 140150965349224] proxy_util.c(1991): AH00927: initializing worker proxy:reverse local
my_php7_project_apache | [Sun Jun 23 10:32:46.677828 2019] [proxy:debug] [pid 27:tid 140150965349224] proxy_util.c(2026): AH00930: initialized pool in child 27 for (*) min=0 max=61 smax=61
my_php7_project_apache | [Sun Jun 23 10:32:46.677947 2019] [proxy:debug] [pid 27:tid 140150965349224] proxy_util.c(1934): AH00925: initializing worker fcgi://php:9000/ shared
my_php7_project_apache | [Sun Jun 23 10:32:46.677985 2019] [proxy:debug] [pid 27:tid 140150965349224] proxy_util.c(1991): AH00927: initializing worker fcgi://php:9000/ local
my_php7_project_apache | [Sun Jun 23 10:32:46.678003 2019] [proxy:debug] [pid 27:tid 140150965349224] proxy_util.c(2026): AH00930: initialized pool in child 27 for (php) min=0 max=61 smax=61
my_php7_project_apache | [Sun Jun 23 10:32:46.678453 2019] [mpm_event:debug] [pid 27:tid 140150953499408] event.c(2314): AH02471: start_threads: Using epoll (wakeable)
my_php7_project_apache | [Sun Jun 23 10:32:46.680333 2019] [proxy:debug] [pid 23:tid 140150965349224] proxy_util.c(1934): AH00925: initializing worker proxy:reverse shared
my_php7_project_apache | [Sun Jun 23 10:32:46.680395 2019] [proxy:debug] [pid 23:tid 140150965349224] proxy_util.c(1991): AH00927: initializing worker proxy:reverse local
my_php7_project_apache | [Sun Jun 23 10:32:46.680475 2019] [proxy:debug] [pid 23:tid 140150965349224] proxy_util.c(2026): AH00930: initialized pool in child 23 for (*) min=0 max=61 smax=61
my_php7_project_apache | [Sun Jun 23 10:32:46.680533 2019] [proxy:debug] [pid 23:tid 140150965349224] proxy_util.c(1934): AH00925: initializing worker fcgi://php:9000/ shared
my_php7_project_apache | [Sun Jun 23 10:32:46.680598 2019] [proxy:debug] [pid 23:tid 140150965349224] proxy_util.c(1991): AH00927: initializing worker fcgi://php:9000/ local
my_php7_project_apache | [Sun Jun 23 10:32:46.680637 2019] [proxy:debug] [pid 23:tid 140150965349224] proxy_util.c(2026): AH00930: initialized pool in child 23 for (php) min=0 max=61 smax=61
my_php7_project_apache | [Sun Jun 23 10:32:46.680786 2019] [mpm_event:debug] [pid 23:tid 140150953499408] event.c(2314): AH02471: start_threads: Using epoll (wakeable)
my_php7_project_apache | [Sun Jun 23 10:57:55.916740 2019] [authz_core:debug] [pid 23:tid 140150953310992] mod_authz_core.c(820): [client 127.0.0.1:53808] AH01626: authorization result of Require all granted: granted
my_php7_project_apache | [Sun Jun 23 10:57:55.916778 2019] [authz_core:debug] [pid 23:tid 140150953310992] mod_authz_core.c(820): [client 127.0.0.1:53808] AH01626: authorization result of <RequireAny>: granted
my_php7_project_apache | [Sun Jun 23 10:57:55.918007 2019] [authz_core:debug] [pid 23:tid 140150953310992] mod_authz_core.c(820): [client 127.0.0.1:53808] AH01626: authorization result of Require all granted: granted
my_php7_project_apache | [Sun Jun 23 10:57:55.918051 2019] [authz_core:debug] [pid 23:tid 140150953310992] mod_authz_core.c(820): [client 127.0.0.1:53808] AH01626: authorization result of <RequireAny>: granted
my_php7_project_apache | [Sun Jun 23 10:57:55.918119 2019] [proxy:debug] [pid 23:tid 140150953310992] mod_proxy.c(1248): [client 127.0.0.1:53808] AH01143: Running scheme fcgi handler (attempt 0)
my_php7_project_apache | [Sun Jun 23 10:57:55.918142 2019] [proxy_fcgi:debug] [pid 23:tid 140150953310992] mod_proxy_fcgi.c(1021): [client 127.0.0.1:53808] AH01076: url: fcgi://php:9000/var/www/html/index.php proxyname: (null) proxyport: 0
my_php7_project_apache | [Sun Jun 23 10:57:55.918149 2019] [proxy_fcgi:debug] [pid 23:tid 140150953310992] mod_proxy_fcgi.c(1028): [client 127.0.0.1:53808] AH01078: serving URL fcgi://php:9000/var/www/html/index.php
my_php7_project_apache | [Sun Jun 23 10:57:55.918170 2019] [proxy:debug] [pid 23:tid 140150953310992] proxy_util.c(2326): AH00942: FCGI: has acquired connection for (php)
my_php7_project_apache | [Sun Jun 23 10:57:55.918186 2019] [proxy:debug] [pid 23:tid 140150953310992] proxy_util.c(2379): [client 127.0.0.1:53808] AH00944: connecting fcgi://php:9000/var/www/html/index.php to php:9000
my_php7_project_apache | [Sun Jun 23 10:57:55.918879 2019] [proxy:debug] [pid 23:tid 140150953310992] proxy_util.c(2588): [client 127.0.0.1:53808] AH00947: connected /var/www/html/index.php to php:9000
my_php7_project_apache | [Sun Jun 23 10:57:55.919164 2019] [proxy:debug] [pid 23:tid 140150953310992] proxy_util.c(3057): AH02824: FCGI: connection established with 172.25.0.4:9000 (php)
my_php7_project_apache | 127.0.0.1 - - [23/Jun/2019:10:57:55 +0000] "GET / HTTP/1.1" 200 2
my_php7_project_apache | [Sun Jun 23 10:57:56.005112 2019] [proxy:debug] [pid 23:tid 140150953310992] proxy_util.c(2341): AH00943: FCGI: has released connection for (php)
my_php7_project_traefik | time="2019-06-23T10:32:56Z" level=info msg="Using TOML configuration file /dev/null"
my_php7_project_traefik | time="2019-06-23T10:32:56Z" level=warning msg="web provider configuration is deprecated, you should use these options : api, rest provider, ping and metrics"
my_php7_project_traefik | time="2019-06-23T10:32:56Z" level=info msg="Traefik version v1.7.12 built on 2019-05-29_07:35:02PM"
my_php7_project_traefik | time="2019-06-23T10:32:56Z" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://docs.traefik.io/basics/#collected-data\n"
my_php7_project_traefik | time="2019-06-23T10:32:56Z" level=info msg="Preparing server http &{Address::80 TLS:<nil> Redirect:<nil> Auth:<nil> WhitelistSourceRange:[] WhiteList:<nil> Compress:false ProxyProtocol:<nil> ForwardedHeaders:0xc00002be40} with readTimeout=0s writeTimeout=0s idleTimeout=3m0s"
my_php7_project_traefik | time="2019-06-23T10:32:56Z" level=info msg="Preparing server traefik &{Address::8080 TLS:<nil> Redirect:<nil> Auth:<nil> WhitelistSourceRange:[] WhiteList:<nil> Compress:false ProxyProtocol:<nil> ForwardedHeaders:0xc00002bea0} with readTimeout=0s writeTimeout=0s idleTimeout=3m0s"
my_php7_project_traefik | time="2019-06-23T10:32:56Z" level=info msg="Starting provider configuration.ProviderAggregator {}"
my_php7_project_traefik | time="2019-06-23T10:32:56Z" level=info msg="Starting server on :80"
my_php7_project_portainer | 2019/06/23 10:32:57 Starting Portainer 1.21.0 on :9000
my_php7_project_traefik | time="2019-06-23T10:32:56Z" level=info msg="Starting server on :8080"
my_php7_project_traefik | time="2019-06-23T10:32:56Z" level=info msg="Starting provider *docker.Provider {\"Watch\":true,\"Filename\":\"\",\"Constraints\":null,\"Trace\":false,\"TemplateVersion\":2,\"DebugLogGeneratedTemplate\":false,\"Endpoint\":\"unix:///var/run/docker.sock\",\"Domain\":\"\",\"TLS\":null,\"ExposedByDefault\":true,\"UseBindPortIP\":false,\"SwarmMode\":false,\"Network\":\"\",\"SwarmModeRefreshSeconds\":15}"
my_php7_project_traefik | time="2019-06-23T10:32:56Z" level=info msg="Server configuration reloaded on :80"
my_php7_project_traefik | time="2019-06-23T10:32:56Z" level=info msg="Server configuration reloaded on :8080"
my_php7_project_php | [23-Jun-2019 10:32:58] NOTICE: fpm is running, pid 1
my_php7_project_php | [23-Jun-2019 10:32:58] NOTICE: ready to handle connections
my_php7_project_php | 172.25.0.6 -  23/Jun/2019:10:57:55 +0000 "GET /index.php" 200
my_php7_project_mailhog | 2019/06/23 10:32:35 Using in-memory storage
my_php7_project_mailhog | 2019/06/23 10:32:36 [SMTP] Binding to address: 0.0.0.0:1025
my_php7_project_mailhog | [HTTP] Binding to address: 0.0.0.0:8025
my_php7_project_mailhog | 2019/06/23 10:32:36 Serving under http://0.0.0.0:8025/
my_php7_project_mailhog | Creating API v1 with WebPath:
my_php7_project_mailhog | Creating API v2 with WebPath:
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events
my_php7_project_mailhog | [APIv1] KEEPALIVE /api/v1/events

.env

### PROJECT SETTINGS

PROJECT_NAME=my_php7_project
PROJECT_BASE_URL=php.def
...

Hosts etc/host

127.0.0.1   php7.def

docker-compose up -d

Creating network "php-7_default" with the default driver
Creating my_php7_project_mailhog   ... done
Creating my_php7_project_php       ... done
Creating my_php7_project_portainer ... done
Creating my_php7_project_traefik   ... done
Creating my_php7_project_apache    ... done
csandanov commented 5 years ago

Your logs show 200 OK on index.php requests 🤷‍♂️ can you perhaps share your logs that happen when you make a request without a startup logs?

peird commented 4 years ago

I know this issue is closed but I came here with the same problem. My problem was that my index.php file was in /var/www/html, it should be in /var/www/html/public as stated in the documentation.