Multisite subsites giving ERR_TOO_MANY_REDIRECTS
mikedoubintchik opened this issue · 8 comments
Codebase
Mounted vanilla multisite codebase
Host OS
macOS Sierra
Docker info output
Containers: 5
Running: 5
Paused: 0
Stopped: 0
Images: 21
Server Version: 17.09.0-ce-rc1
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 ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 3f2f8b84a77f73d38244dd690525642a72156c64
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.46-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.952GiB
Name: moby
ID: PJNX:RV35:2FY7:MOO4:STFK:UB27:2JWX:IVTR:JLHF:JAKN:UKT7:X3PA
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 66
Goroutines: 72
System Time: 2017-09-18T19:36:33.885137581Z
EventsListeners: 2
No Proxy: *.local, 169.254/16
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Docker compose file
version: "2"
services:
mariadb:
image: wodby/mariadb:10.1-2.3.3
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: <project-name>
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
volumes:
- /path/to/project/init/db:/docker-entrypoint-initdb.d # Place init .sql file(s) here.
- /path/to/project/data/db:/var/lib/mysql # I want to manage volumes manually.
php:
# image: wodby/wordpress:4-7.1-2.2.0
image: wodby/wordpress-php:7.1-2.2.0
environment:
SHORT_OPEN_TAG: "On"
PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
PHP_XDEBUG: 1
PHP_XDEBUG_DEFAULT_ENABLE: 1
PHP_XDEBUG_REMOTE_CONNECT_BACK: 0 # This is needed to respect remote.host setting bellow
PHP_XDEBUG_REMOTE_HOST: "10.254.254.254" # You will also need to 'sudo ifconfig lo0 alias 10.254.254.254'
volumes:
# - /Users/ninja/Sites/codegeek/viasat-dealer/www:/var/www/html
- docker-sync-<project-name>:/var/www/html # Docker-sync
nginx:
image: wodby/wordpress-nginx:4-1.13-2.2.0
environment:
NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off"
NGINX_ERROR_LOG_LEVEL: debug
NGINX_BACKEND_HOST: php
NGINX_SERVER_ROOT: /var/www/html
volumes:
# - /path/to/project/www:/var/www/html
- docker-sync-<project-name>:/var/www/html # Docker-sync
depends_on:
- php
labels:
- 'traefik.backend=<project-name>_nginx'
- 'traefik.port=80'
- 'traefik.frontend.rule=Host:<project-name>.docker.localhost'
volumes:
docker-sync-<project-name>:
external: true
Logs output
nginx_1 | 2017/09/18 19:36:02 [notice] 24#24: *123 "/wp-admin$" does not match "/test/wp-admin/", client: 172.27.0.5, server: wordpress, request: "GET /test/wp-admin/ HTTP/1.1", host: "<project-name>.docker.localhost"
nginx_1 | 2017/09/18 19:36:02 [notice] 24#24: *123 "/wp-admin$" does not match "/index.php", client: 172.27.0.5, server: wordpress, request: "GET /test/wp-admin/ HTTP/1.1", host: "<project-name>.docker.localhost"
nginx_1 | 172.27.0.5 - - [18/Sep/2017:19:36:02 +0000] "GET /test/wp-admin/ HTTP/1.1" 302 5 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"
nginx_1 | 2017/09/18 19:36:02 [notice] 24#24: *123 "/wp-admin$" does not match "/test/wp-admin/", client: 172.27.0.5, server: wordpress, request: "GET /test/wp-admin/ HTTP/1.1", host: "<project-name>.docker.localhost"
nginx_1 | 2017/09/18 19:36:02 [notice] 24#24: *123 "/wp-admin$" does not match "/index.php", client: 172.27.0.5, server: wordpress, request: "GET /test/wp-admin/ HTTP/1.1", host: "<project-name>.docker.localhost"
nginx_1 | 172.27.0.5 - - [18/Sep/2017:19:36:03 +0000] "GET /test/wp-admin/ HTTP/1.1" 302 5 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"
I realized the trick was to enable subdomains instead of subfolders and listing out all of the subdomains in the frontend rule of the nginx container.
Does anyone know how to accomplish the same thing with subfolders and perhaps a regular expression instead of listing each specific item.
I use subdomains only.
And i use next rule for nginx container
- 'traefik.frontend.rule=HostRegexp:{subdomain:.+}.yoursite.dev,yoursite.dev'
What is your nginx image tag?
@TrilipuT Thank you. That's exactly what I was looking for!
@csandanov I'm using wodby/wordpress-nginx:4-1.13-2.2.0
For apache installation and multisite with subfolders, I found a workaround modifyng .htaccess only.
Simply add "DirectoryIndex index.php" to the top.
It seems that apache installation have no default conf.
example of this .htaccess:
DirectoryIndex index.php
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
@TrilipuT With your subdomain wildcard rule, it seems like none of the other container rules work. For example, I can't reach pma.wp.docker.localhost. Any ideas how to get around this?