Merge ~tcuthbert/charm-k8s-wordpress/+git/wordpress-k8s-image-builder:master into ~wordpress-charmers/charm-k8s-wordpress/+git/wordpress-k8s-image-builder:master

Proposed by Thomas Cuthbert
Status: Merged
Approved by: Haw Loeung
Approved revision: 33352a089fc2e7e9262c77958b322036d0ce787d
Merged at revision: 31935ce1ccf73af80eff56b73c3e9205430d1174
Proposed branch: ~tcuthbert/charm-k8s-wordpress/+git/wordpress-k8s-image-builder:master
Merge into: ~wordpress-charmers/charm-k8s-wordpress/+git/wordpress-k8s-image-builder:master
Diff against target: 77 lines (+27/-6)
3 files modified
Dockerfile (+4/-3)
files/docker-php.conf (+6/-0)
files/wp-config.php (+17/-3)
Reviewer Review Type Date Requested Status
Haw Loeung +1 Approve
Canonical IS Reviewers Pending
Review via email: mp+382824@code.launchpad.net

Commit message

Docker image configuration changes:

    * Update wp-config to support being behind TLS reverse proxy and move debug logging statements up so they actually are applied
    * Permalinks require mod_rewrite enabled for the directory root
    * Add missing required packages for WordPress and WP openid plugins to work

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Unable to determine commit message from repository - please click "Set commit message" and enter the commit message manually.

Revision history for this message
Haw Loeung (hloeung) wrote :

LGTM

review: Approve (+1)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 31935ce1ccf73af80eff56b73c3e9205430d1174

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Dockerfile b/Dockerfile
2index 2c86bef..b2d507a 100644
3--- a/Dockerfile
4+++ b/Dockerfile
5@@ -19,8 +19,8 @@ RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selectio
6 # Update all packages, remove cruft, install required packages, configure apache
7 RUN apt-get update && apt-get -y dist-upgrade \
8 && apt-get --purge autoremove -y \
9- && apt-get install -y apache2 curl libapache2-mod-php php php-gd php-mysql \
10- php-symfony-yaml pwgen python3 python3-yaml ssl-cert \
11+ && apt-get install -y apache2 curl libapache2-mod-php php php-curl php-gd php-gmp php-mysql \
12+ php-symfony-yaml php-xml pwgen python3 python3-yaml ssl-cert libgmp-dev \
13 && sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS" \
14 && . "$APACHE_ENVVARS" \
15 && for dir in "$APACHE_LOCK_DIR" "$APACHE_RUN_DIR" "$APACHE_LOG_DIR"; do rm -rvf "$dir"; mkdir -p "$dir"; chown "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; chmod 777 "$dir"; done \
16@@ -33,7 +33,8 @@ RUN apt-get update && apt-get -y dist-upgrade \
17 COPY ./files/docker-php.conf $APACHE_CONFDIR/conf-available/docker-php.conf
18 RUN a2enconf docker-php \
19 && a2dismod mpm_event \
20- && a2enmod mpm_prefork
21+ && a2enmod mpm_prefork \
22+ && a2enmod rewrite
23
24 # Install the main Wordpress code, this will be our only site so /var/www/html is fine
25 RUN curl -o wordpress.tar.gz -fSL "https://wordpress.org/latest.tar.gz" \
26diff --git a/files/docker-php.conf b/files/docker-php.conf
27index af22747..283d871 100644
28--- a/files/docker-php.conf
29+++ b/files/docker-php.conf
30@@ -8,4 +8,10 @@ DirectoryIndex index.php index.html
31 <Directory /var/www/>
32 Options -Indexes
33 AllowOverride All
34+ RewriteEngine On
35+ RewriteBase /
36+ RewriteRule ^index\.php$ - [L]
37+ RewriteCond %{REQUEST_FILENAME} !-f
38+ RewriteCond %{REQUEST_FILENAME} !-d
39+ RewriteRule . /index.php [L]
40 </Directory>
41diff --git a/files/wp-config.php b/files/wp-config.php
42index 7b9a387..158b0db 100644
43--- a/files/wp-config.php
44+++ b/files/wp-config.php
45@@ -12,6 +12,20 @@
46
47 /* That's all, stop editing! Happy blogging. */
48
49+/** Enable container debug level logging. **/
50+if ( getenv("WORDPRESS_DEBUG") ) {
51+ define( 'WP_DEBUG', true );
52+ define( 'WP_DEBUG_DISPLAY', false );
53+ define( 'WP_DEBUG_LOG', '/dev/stderr' );
54+}
55+
56+/** Fixes for mixed content when WordPress is behind nginx TLS reverse proxy.
57+ * https://ahenriksson.com/2020/01/27/how-to-set-up-wordpress-behind-a-reverse-proxy-when-using-nginx/
58+ * */
59+define('FORCE_SSL_ADMIN', true);
60+if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
61+ $_SERVER['HTTPS']='on';
62+
63 /** Absolute path to the WordPress directory. */
64 if ( !defined('ABSPATH') )
65 define('ABSPATH', dirname(__FILE__) . '/');
66@@ -32,8 +46,8 @@ define( 'WP_HTTP_BLOCK_EXTERNAL', true );
67 define( 'AUTOMATIC_UPDATER_DISABLED', true );
68 define( 'WP_AUTO_UPDATE_CORE', false );
69
70-/** Enable container debug level logging. **/
71-if ( getenv("WORDPRESS_DEBUG") )
72- define( 'WP_DEBUG', true );
73+$http_host = $_SERVER['HTTP_HOST'];
74+define('WP_HOME',"https://$http_host");
75+define('WP_SITEURL',"https://$http_host");
76
77 remove_filter('template_redirect', 'redirect_canonical');

Subscribers

People subscribed via source and target branches