Title: Problem with WordPress behind Reverse Proxy
Last modified: February 18, 2020

---

# Problem with WordPress behind Reverse Proxy

 *  [prynhart](https://wordpress.org/support/users/prynhart/)
 * (@prynhart)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/problem-with-wordpress-behind-reverse-proxy/)
 * Things almost work – but not quite!
 * We are trying to run WordPress 5.3.2 behind a Reverse Proxy (hosted on Citrix
   Netscaler VPX appliances). We are wanting to do SSL offload – i.e. internally
   we are talking only to a RHEL server on Port 80.
 * We are doing a multisite installation and the canonical (internal) name is [http://sites.massey.ac.nz](http://sites.massey.ac.nz),
   whereas the virtualised / Rev Proxy address is:
 * [https://www.massey.ac.nz/sites2/](https://www.massey.ac.nz/sites2/)
 * This is the block of code that I have added to the top of our wp-config.php
 *     ```
       if ($_SERVER['HTTP_CS_VS'] == 'cs-vs-ssl-proxy') { 
         /* Request is from Rev Proxy */
         $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
         $_SERVER['HTTP_X_FORWARDED_SERVER'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
         define('WP_HOME', 'https://www.massey.ac.nz/sites2');
         define('WP_SITEURL', 'https://www.massey.ac.nz/sites2');
         $_SERVER['REQUEST_URI'] = str_replace("wordpress", "sites2", $_SERVER['REQUEST_URI']);
       }
       ```
   
 * I would expect this to rewrite ALL URLs and almost all of the URLs are. But the
   problem is some resources are still coming through with the canonical (i.e. [http://sites.massey.ac.nz](http://sites.massey.ac.nz)
   URL – particularly some key components of WordPress. For example, in my Safari
   developer console:
 * [blocked] The page at [https://www.massey.ac.nz/sites2/](https://www.massey.ac.nz/sites2/)
   was not allowed to run insecure content from [http://sites.massey.ac.nz/wp-includes/js/wp-emoji-release.min.js?ver=5.3.2](http://sites.massey.ac.nz/wp-includes/js/wp-emoji-release.min.js?ver=5.3.2).
 * I’m not sure how to go about troubleshooting this. Could someone please help.
 * Here is a screenshot showing the problem. Please note the red box highlighted
   in the Safari Developer console:
 * [https://ibb.co/mh82ThZ](https://ibb.co/mh82ThZ)
 * Thanks in Advance,
 * Patrick
    -  This topic was modified 6 years, 3 months ago by [prynhart](https://wordpress.org/support/users/prynhart/).
    -  This topic was modified 6 years, 3 months ago by [prynhart](https://wordpress.org/support/users/prynhart/).
    -  This topic was modified 6 years, 3 months ago by [prynhart](https://wordpress.org/support/users/prynhart/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fproblem-with-wordpress-behind-reverse-proxy%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [JNashHawkins](https://wordpress.org/support/users/jnashhawkins/)
 * (@jnashhawkins)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/problem-with-wordpress-behind-reverse-proxy/#post-12450600)
 * I’d get the WordPress fixed first, probably the best fix would be to get a cert
   for the origin box and rename the origin to its real name (public name) via domain
   mapping… a lot less trouble.
 * Now bring your proxy back.
 *  [johnkawakami](https://wordpress.org/support/users/johnkawakami/)
 * (@johnkawakami)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/problem-with-wordpress-behind-reverse-proxy/#post-13168112)
 * I’d check that the siteurl and home in the wp_options have “https” instead of“
   http”.
 * Also, I have a hack, probably not wise, in a short mu-plugin, that just gets 
   rid of the scheme entirely, because that’s how it’s done nowadays:
 *     ```
       function jk_force_relative( $url, $scheme, $orig_scheme ) {
           if ($scheme == 'http') {
               $url = str_replace( 'http://', '//', $url );
           }
           return $url;
       }
   
       // Now we set that function up to execute when the admin_notices action is called.
       add_filter( 'set_url_scheme', 'jk_force_relative', 10, 3 );
       ```
   
    -  This reply was modified 5 years, 10 months ago by [johnkawakami](https://wordpress.org/support/users/johnkawakami/).
    -  This reply was modified 5 years, 10 months ago by [johnkawakami](https://wordpress.org/support/users/johnkawakami/).

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Problem with WordPress behind Reverse Proxy’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [johnkawakami](https://wordpress.org/support/users/johnkawakami/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/problem-with-wordpress-behind-reverse-proxy/#post-13168112)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
