Created
June 28, 2015 17:59
-
-
Save georgioupanayiotis/66ab807e783442431ba6 to your computer and use it in GitHub Desktop.
Symfony2: app_dev.php allow access only to IP address
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
$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