Procházet zdrojové kódy

Set HTTP_HOST and HTTPS correctly based on proxy values

nginx config sets these values in the request headers. WP uses
these values to generate full urls for all links

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
Girish Ramakrishnan před 10 roky
rodič
revize
3161af56de
1 změnil soubory, kde provedl 14 přidání a 0 odebrání
  1. 14 0
      wp-config.php

+ 14 - 0
wp-config.php

@@ -88,3 +88,17 @@ if ( !defined('ABSPATH') )
 
 /** Sets up WordPress vars and included files. */
 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
+ */
+// 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_FOR'];
+
+    if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
+        $_SERVER['HTTPS']='on';
+}
+