Skip to content

Instantly share code, notes, and snippets.

@buchizo
Created February 13, 2017 15:21
Show Gist options
  • Save buchizo/1b619c5461295822f0c45e666ba716bf to your computer and use it in GitHub Desktop.
Save buchizo/1b619c5461295822f0c45e666ba716bf to your computer and use it in GitHub Desktop.
WordPress on Azure App Service via nginx (require any X-FORWARDED headers)
if ( array_key_exists( "HTTP_X_FORWARDED_SERVER", $_SERVER ) ) {
if ( ! empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) {
$_SERVER['HTTPS']='on';
}
define( "WP_SITEURL", "http://" . $_SERVER["HTTP_X_FORWARDED_SERVER"] );
define( "WP_HOME", "http://" . $_SERVER["HTTP_X_FORWARDED_SERVER"] );
$_SERVER['HTTP_HOST'] = $_SERVER["HTTP_X_FORWARDED_SERVER"];
$_SERVER['SERVER_NAME'] = $_SERVER["HTTP_X_FORWARDED_SERVER"];
} else {
define( "WP_SITEURL", "http://yoursite.azurewebsites.net" );
define( "WP_HOME", "http://yoursite.azurewebsites.net" );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment