<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
// for more information
//umask(0000);
// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
// if (isset($_SERVER['HTTP_CLIENT_IP'])
// || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
// || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']) || php_sapi_name() === 'cli-server')
// ) {
// header('HTTP/1.0 403 Forbidden');
// exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
// }
require __DIR__ . '/../vendor/autoload.php';
Debug::enable();
$kernel = new AppKernel('dev', true);
if (PHP_VERSION_ID < 70000) {
$kernel->loadClassCache();
}
$request = Request::createFromGlobals();
/*
* Enable one of trusted proxy configurations below
*
* This tells Symfony Router to trust `X-Forwarded-*` headers from reverse proxies in front of it (e.g. Varnish). If
* this is not configured properly for the respective environment, the Router will ignore the headers and e.g. generate
* http-only links (ignoring `X-Forwarded-Proto` header that indicates that website uses https).
*
* See:
*
* - https://symfony.com/blog/fixing-the-trusted-proxies-configuration-for-symfony-3-3
* - https://stackoverflow.com/a/50110665/282325
*/
$dockerIpRanges = [
'127.0.0.1',
'10.0.0.0/8',
'172.16.0.0/12',
'192.168.0.0/16',
];
$zutomIpRanges = [
'127.0.0.1',
];
$cloudflareIpRanges = [
// https://www.cloudflare.com/ips/
'103.21.244.0/22',
'103.22.200.0/22',
'103.31.4.0/22',
'104.16.0.0/12',
'108.162.192.0/18',
'131.0.72.0/22',
'141.101.64.0/18',
'162.158.0.0/15',
'172.64.0.0/13',
'173.245.48.0/20',
'188.114.96.0/20',
'190.93.240.0/20',
'197.234.240.0/22',
'198.41.128.0/17',
];
// Request::setTrustedProxies(array_merge($dockerIpRanges), Request::HEADER_X_FORWARDED_ALL); // docker
Request::setTrustedProxies(array_merge($zutomIpRanges), Request::HEADER_X_FORWARDED_ALL); // Zutom PROD not behind Cloudflare
// Request::setTrustedProxies(array_merge($zutomIpRanges, $cloudflareIpRanges), Request::HEADER_X_FORWARDED_ALL); // Zutom PROD behind Cloudflare
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);