Skip to content

Instantly share code, notes, and snippets.

@cgrymala
Created September 1, 2015 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgrymala/197e1e587bf49785b095 to your computer and use it in GitHub Desktop.
Save cgrymala/197e1e587bf49785b095 to your computer and use it in GitHub Desktop.
Attempt to fix the way CASMaestro/phpCAS on WPEngine sends the application URL to the CAS server
<?php
if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
if ( isset( $_SERVER['HTTP_X_FORWARDED_PORT'] ) && ! empty( $_SERVER['HTTP_X_FORWARDED_PORT'] ) ) {
$ports = explode(',', $_SERVER['HTTP_X_FORWARDED_PORT']);
error_log( 'The forwarded Port var is set to: ' . $ports[0] );
} else if ( isset( $_SERVER['SERVER_PORT'] ) && ! empty( $_SERVER['SERVER_PORT'] ) ) {
error_log( 'The server Port var is set to: ' . $_SERVER['SERVER_PORT'] );
$_SERVER['SERVER_PORT'] = 443;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment