Skip to content

Instantly share code, notes, and snippets.

@georgioupanayiotis
Created June 28, 2015 17:59
Show Gist options
  • Save georgioupanayiotis/66ab807e783442431ba6 to your computer and use it in GitHub Desktop.
Save georgioupanayiotis/66ab807e783442431ba6 to your computer and use it in GitHub Desktop.
Symfony2: app_dev.php allow access only to IP address
$whitelistIPs = array('127.0.0.1', 'fe80::1', '::1', 'my.organisation.ip.address');
//allow app_dev.php only under these conditions (prevent for production environment) uses HTTP_X_FORWARDED_FOR because behind load balancer
if (
isset($_SERVER['HTTP_X_FORWARDED_FOR']) &&
( ! in_array(@$_SERVER['HTTP_X_FORWARDED_FOR'], $whitelistIPs) )
){
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access the development environment.');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment