Last active
August 17, 2022 10:53
-
-
Save lynt-smitka/1a894ef46dbb4864e681de00abe58dd0 to your computer and use it in GitHub Desktop.
Small script to detect reverse proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<script> | |
var serverport = '<?php echo intval($_SERVER['SERVER_PORT']);?>'; | |
var browserport = window.location.port || (window.location.protocol === 'https:' ? '443' : '80'); | |
var color = (serverport === browserport ? 'green' : 'red'); | |
var text = "<pre style='color:#color'>Server port: "+serverport+"<br>Browser port: "+browserport+"</pre>"; | |
document.write(text.replace("#color",color)); | |
</script> | |
<pre> | |
<?php | |
echo 'IP: '.htmlspecialchars($header.": ".$_SERVER['REMOTE_ADDR'], ENT_QUOTES, 'UTF-8')."\n\n"; | |
$headers = array('X_FORWARDED_FOR', 'X_FORWARDED_PROTO', 'X_FORWARDED_HOST', 'X_FORWARDED', 'FORWARDED', 'CF_CONNECTING_IP', 'CF_VISITOR'); | |
foreach ($headers as $header){ | |
if(isset($_SERVER['HTTP_'.$header])){ | |
echo htmlspecialchars($header.": ".$_SERVER['HTTP_'.$header], ENT_QUOTES, 'UTF-8')."\n"; | |
} | |
} | |
?> | |
</pre> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment