nginx proxy causes 404
willopez opened this issue · 3 comments
Codebase
Custom mounted
Host OS
macOS Sierra
Docker info output
Running: 19
Paused: 0
Stopped: 4
Images: 602
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 Mac
OSType: linux
Architecture: x86_64
CPUs: 5
Total Memory: 7.786GiB
Name: linuxkit-025000000001
ID: ZICJ:5JFF:MK44:Y4D2:RNLN:KZAW:E7IA:JBJW:IGMH:PBNY:VBQ5:QUHQ
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 201
Goroutines: 212
System Time: 2019-03-22T04:07:43.76863772Z
EventsListeners: 7
HTTP Proxy: gateway.docker.internal:3128
HTTPS Proxy: gateway.docker.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
.env
PROJECT_NAME=sites
PROJECT_BASE_URL=wpmain.local
...
rest of unmodified vars
...
Docker compose file
Make sure you remove all commented services.
version: "3"
services:
mariadb:
image: wodby/mariadb:$MARIADB_TAG
container_name: "${PROJECT_NAME}_mariadb"
stop_grace_period: 30s
environment:
MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
MYSQL_DATABASE: $DB_NAME
MYSQL_USER: $DB_USER
MYSQL_PASSWORD: $DB_PASSWORD
volumes:
# - ./mariadb-init:/docker-entrypoint-initdb.d # Place init .sql file(s) here.
- ./data/:/var/lib/mysql # I want to manage volumes manually.
php:
image: wodby/wordpress-php:$PHP_TAG
container_name: "${PROJECT_NAME}_php"
build: .
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
## Read instructions at https://wodby.com/stacks/wordpress/docs/local/xdebug/
# PHP_XDEBUG: 1
# PHP_XDEBUG_DEFAULT_ENABLE: 1
# PHP_XDEBUG_REMOTE_CONNECT_BACK: 0
# PHP_IDE_CONFIG: serverName=my-ide
# PHP_XDEBUG_REMOTE_HOST: 172.17.0.1 # Linux
# PHP_XDEBUG_REMOTE_HOST: 10.254.254.254 # macOS
# PHP_XDEBUG_REMOTE_HOST: 10.0.75.1 # Windows
# volumes:
# - ./:/var/www/html
## For macOS users (https://wodby.com/stacks/wordpress/docs/local/docker-for-mac/)
# - ./:/var/www/html:cached # User-guided caching
# - docker-sync:/var/www/html # Docker-sync
## For XHProf and Xdebug profiler traces
# - files:/mnt/files
# depends_on:
# - mariadb
nginx:
image: wodby/nginx:$NGINX_TAG
container_name: "${PROJECT_NAME}_nginx"
depends_on:
- php
environment:
NGINX_STATIC_OPEN_FILE_CACHE: "off"
NGINX_ERROR_LOG_LEVEL: error
NGINX_BACKEND_HOST: php
NGINX_VHOST_PRESET: wordpress
NGINX_SERVER_ROOT: /var/www/html/web
# volumes:
# - ./:/var/www/html
# Options for macOS users (https://wodby.com/stacks/wordpress/docs/local/docker-for-mac/)
# - ./:/var/www/html:cached # User-guided caching
# - docker-sync:/var/www/html # Docker-sync
labels:
- 'traefik.backend=${PROJECT_NAME}_nginx'
- 'traefik.port=80'
- 'traefik.frontend.rule=Host:${PROJECT_BASE_URL},site1.local,site3.local'
pma:
image: phpmyadmin/phpmyadmin
container_name: "${PROJECT_NAME}_pma"
environment:
PMA_HOST: $DB_HOST
PMA_USER: $DB_USER
PMA_PASSWORD: $DB_PASSWORD
PHP_UPLOAD_MAX_FILESIZE: 1G
PHP_MAX_INPUT_VARS: 1G
labels:
- 'traefik.backend=${PROJECT_NAME}_pma'
- 'traefik.port=80'
- 'traefik.frontend.rule=Host:pma.${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:
- '80:80'
# - '8080:8080' # Dashboard
volumes:
- /var/run/docker.sock:/var/run/docker.sock
Dockerfile
FROM wodby/wordpress-php:7.2-dev-4.12.5
COPY ./web /var/www/html/web
When I hit the localhost url I get a 404 from Nginx. If I ssh into the nginx container, I see that there is no web
folder(expected, since I am commenting out the volumes in the nginx section of the docker-compose.yml) I don't see why is it needed there, since it's just proxying to the php container where I have backed the wordpress files, via the Dockerfile
what I am missing? why does the nginx container need to have access to the WordPress codebase? I want the php(WordPress) to be stateless, and that is why I am backing in the Wordpress files.
@csandanov any insight into this issue? thanks in advance.
I don't see why is it needed there, since it's just proxying to the php container where I have backed the wordpress files, via the Dockerfile
it's needed because you have static files in the codebase (WP core, plugins, themes), plus you have wp-content/uploads
directory.
got it, thanks.