Skip to content

Reverse Proxy SSL Support / Security Improvements #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2014
Merged
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
10 changes: 9 additions & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just ran a test build on this and got: /usr/src/wordpress/docker-entrypoint.sh: line 117: syntax error: unexpected end of file. It worked when I unindented the heredoc.

Also, @tianon had you put that in the wrong spot (it was supposed to be in the if [ ! -e wp-config.php ] so that we get the default config too.

I already made these changes locally, so I'll just merge in your PR with my changes too.

Thanks for the contribution @drewwestphal!

if [ ! -e .htaccess ]; then
cat > .htaccess <<-'EOF'
RewriteEngine On
Expand Down