From c726ea4f615e29dd6e883c20937f0201de145439 Mon Sep 17 00:00:00 2001 From: drew Date: Wed, 16 Jul 2014 00:11:00 -0400 Subject: [PATCH 1/2] Don't copy shell scripts and conf files into ht root. Allow for reverse-proxy SSL configurations. Amended with changes suggested by tianon. --- docker-entrypoint.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index be6af5c008..b21ea83d80 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -25,8 +25,16 @@ fi if ! [ -e index.php -a -e wp-includes/version.php ]; then echo >&2 "WordPress not found in $(pwd) - copying now..." - rsync --archive --one-file-system --quiet /usr/src/wordpress/ ./ + rsync --archive --one-file-system --quiet --exclude='*.sh' --exclude='*.conf' --exclude='Dockerfile' /usr/src/wordpress/ ./ echo >&2 "Complete! WordPress has been successfully copied to $(pwd)" + cat >> wp-config.php <<'EOPHP' + + // If we're behind a proxy server and using HTTPS, we need to alert Wordpress of that fact + // see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { + $_SERVER['HTTPS'] = 'on'; + } + EOPHP if [ ! -e .htaccess ]; then cat > .htaccess <<-'EOF' RewriteEngine On From eca82129e43d08af208de0683edaa8549c6197cd Mon Sep 17 00:00:00 2001 From: Joe Ferguson Date: Fri, 18 Jul 2014 17:16:06 -0600 Subject: [PATCH 2/2] quick fix adjust the wp-config in the right spot --- docker-entrypoint.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index b21ea83d80..5c34d61efe 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -27,14 +27,6 @@ if ! [ -e index.php -a -e wp-includes/version.php ]; then echo >&2 "WordPress not found in $(pwd) - copying now..." rsync --archive --one-file-system --quiet --exclude='*.sh' --exclude='*.conf' --exclude='Dockerfile' /usr/src/wordpress/ ./ echo >&2 "Complete! WordPress has been successfully copied to $(pwd)" - cat >> wp-config.php <<'EOPHP' - - // If we're behind a proxy server and using HTTPS, we need to alert Wordpress of that fact - // see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy - if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { - $_SERVER['HTTPS'] = 'on'; - } - EOPHP if [ ! -e .htaccess ]; then cat > .htaccess <<-'EOF' RewriteEngine On @@ -51,6 +43,14 @@ fi if [ ! -e wp-config.php ]; then cp wp-config-sample.php wp-config.php + cat >> wp-config.php <<'EOPHP' + +// If we're behind a proxy server and using HTTPS, we need to alert Wordpress of that fact +// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy +if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { + $_SERVER['HTTPS'] = 'on'; +} +EOPHP fi set_config() {