Skip to content

Commit

Permalink
fixed #306 - csrf error when proxied with termination at the reverse …
Browse files Browse the repository at this point in the history
…proxy
  • Loading branch information
stephenlawrence committed Mar 20, 2021
1 parent b3f38dd commit da3a42b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion functions.php
Expand Up @@ -881,9 +881,16 @@ function redirect_visitor($url = '')
function base_url(){
// We don't want to re-write the base_url value when we are being called by a plugin
if(!preg_match('/plug-ins*/', $_SERVER['REQUEST_URI'])) {
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
$proto = $_SERVER['HTTP_X_FORWARDED_PROTO'];
} elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
$proto = 'https';
} else {
$proto = 'http';
}
return sprintf(
"%s://%s",
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
$proto,
$_SERVER['HTTP_HOST'].dirname($_SERVER['REQUEST_URI'])
);
} else {
Expand Down

0 comments on commit da3a42b

Please sign in to comment.