Selaa lähdekoodia

Set WP_HOME and WP_SITEURL

https://cmanios.wordpress.com/2014/04/12/nginx-https-reverse-proxy-to-wordpress-with-apache-http-and-different-port/
https://wordpress.org/support/topic/wordpress-behind-reverse-proxy-1
https://wordpress.org/support/topic/wp_home-and-wp_siteurl
Girish Ramakrishnan 10 vuotta sitten
vanhempi
commit
a9afee957e
2 muutettua tiedostoa jossa 7 lisäystä ja 2 poistoa
  1. 2 0
      start.sh
  2. 5 2
      wp-config.php.template

+ 2 - 0
start.sh

@@ -25,6 +25,8 @@ sed -e "s/define('DB_NAME',.*/define('DB_NAME', '${db}');/" \
     -e "s/define('DB_USER',.*/define('DB_USER', '${username}');/" \
     -e "s/define('DB_PASSWORD',.*/define('DB_PASSWORD', '${password}');/" \
     -e "s/define('DB_HOST',.*/define('DB_HOST', '${host}');/" \
+    -e "s|define('WP_HOME',.*|define('WP_HOME', 'https://$(hostname -f)');|" \
+    -e "s|define('WP_SITEURL',.*|define('WP_SITEURL', 'https://$(hostname -f)');|" \
     -i /app/data/wp-config.php
 
 /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i MediaWiki

+ 5 - 2
wp-config.php.template

@@ -92,12 +92,15 @@ require_once(ABSPATH . 'wp-settings.php');
 /*
  http://cmanios.wordpress.com/2014/04/12/nginx-https-reverse-proxy-to-wordpress-with-apache-http-and-different-port/
  http://wordpress.org/support/topic/compatibility-with-wordpress-behind-a-reverse-proxy
+ https://wordpress.org/support/topic/wp_home-and-wp_siteurl
  */
-// If WordPress is behind reverse proxy
-// which proxies https to http
+// If WordPress is behind reverse proxy which proxies https to http
 if (!empty( $_SERVER['HTTP_X_FORWARDED_FOR'])) {
     $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
 
+    define('WP_HOME', '');
+    define('WP_SITEURL', '');
+
     if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
         $_SERVER['HTTPS']='on';
 }