diff --git a/.env.example b/.env.example index 6974d8554611a..dddbb4be4c260 100644 --- a/.env.example +++ b/.env.example @@ -14,6 +14,10 @@ LOCAL_PORT=8889 # Where to run WordPress from. Valid options are 'src' and 'build'. LOCAL_DIR=src +# Whether or not to enable text compression (gzip) in the web server. +# Valid options are 'on' and 'off'. +LOCAL_NGINX_COMPRESSION=off + # The PHP version to use. Valid options are 'latest', and '{version}-fpm'. LOCAL_PHP=latest diff --git a/docker-compose.yml b/docker-compose.yml index 7ab6ae8c9b4d5..02cd542c245db 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,13 +14,14 @@ services: environment: LOCAL_DIR: ${LOCAL_DIR-src} + LOCAL_NGINX_COMPRESSION: ${LOCAL_NGINX_COMPRESSION:-off} volumes: - ./tools/local-env/default.template:/etc/nginx/conf.d/default.template - ./:/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 "envsubst '$$LOCAL_DIR $$LOCAL_NGINX_COMPRESSION' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'" depends_on: php: diff --git a/tools/local-env/default.template b/tools/local-env/default.template index 995913fb453a2..4d8dec3c131fc 100644 --- a/tools/local-env/default.template +++ b/tools/local-env/default.template @@ -15,6 +15,21 @@ server { absolute_redirect off; + gzip ${LOCAL_NGINX_COMPRESSION}; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 5; + gzip_min_length 256; + gzip_types + application/javascript + text/javascript + application/json + application/xml + application/rss+xml + text/css + text/plain + image/svg+xml; + if (!-e $request_filename) { rewrite /wp-admin$ $scheme://$host$request_uri/ permanent; rewrite ^(/[^/]+)?(/wp-.*) $2 last;