Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,30 @@ services:
# The web server container.
##
wordpress-develop:
image: nginx:alpine

image: httpd:alpine
networks:
- wpdevnet

ports:
- ${LOCAL_PORT-8889}:80

environment:
LOCAL_DIR: ${LOCAL_DIR-src}

volumes:
- ./tools/local-env/default.template:/etc/nginx/conf.d/default.template
- ./tools/local-env/apache-vhost.conf:/usr/local/apache2/conf/extra/httpd-vhosts.conf
- ./:/var/www

# Load our config file, substituting environment variables into the config.
command: /bin/sh -c "envsubst '$$LOCAL_DIR' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"

command: >
/bin/sh -c "
sed -e '/Include conf\\/extra\\/httpd-vhosts.conf/s/^#//' /usr/local/apache2/conf/httpd.conf > /tmp/httpd.conf &&
cat /tmp/httpd.conf > /usr/local/apache2/conf/httpd.conf &&
rm /tmp/httpd.conf &&
echo 'LoadModule rewrite_module modules/mod_rewrite.so' >> /usr/local/apache2/conf/httpd.conf &&
echo 'LoadModule proxy_module modules/mod_proxy.so' >> /usr/local/apache2/conf/httpd.conf &&
echo 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so' >> /usr/local/apache2/conf/httpd.conf &&
echo 'LoadModule proxy_http_module modules/mod_proxy_http.so' >> /usr/local/apache2/conf/httpd.conf &&
sed -e 's/\$$LOCAL_DIR/$${LOCAL_DIR}/g' /usr/local/apache2/conf/extra/httpd-vhosts.conf > /tmp/httpd-vhosts.conf &&
cat /tmp/httpd-vhosts.conf > /usr/local/apache2/conf/extra/httpd-vhosts.conf &&
rm /tmp/httpd-vhosts.conf &&
exec httpd-foreground
"
depends_on:
php:
condition: service_started
Expand Down
40 changes: 40 additions & 0 deletions tools/local-env/apache-vhost.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<VirtualHost *:80>
ServerName localhost
# See https://core.trac.wordpress.org/ticket/63316#comment:5
HttpProtocolOptions Unsafe
DocumentRoot "/var/www/${LOCAL_DIR}"
DirectoryIndex index.php index.html

<Directory "/var/www/${LOCAL_DIR}">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

<FilesMatch \.php$>
SetHandler "proxy:fcgi://php:9000"
</FilesMatch>

# WordPress rewrite rules
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/wp-admin$ /wp-admin/ [R=301,L]
RewriteRule ^(/[^/]+)?(/wp-.*) $2 [L]
RewriteRule ^(/[^/]+)?(/.*\.php) $2 [L]
RewriteRule . index.php [L]

# Reverse Proxy configuration for PHP-FPM
ProxyPreserveHost On
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://php:9000/var/www/${LOCAL_DIR}/$1
ProxyTimeout 300

ErrorLog /proc/self/fd/2
CustomLog /proc/self/fd/1 combined
LogLevel debug

<IfModule mod_headers.c>
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-Content-Type-Options "nosniff"
</IfModule>
</VirtualHost>