I'm working on an Silex project and run into an issue with wrong url's when calling the site with a proxy.
Sitename without proxy: http://sitename.com/someFile.php
Sitename with proxy: https://sslsites.com/sitename.com/someFile.php
$_SERVER['HTTP_X_FORWARDED_HOST']: 'sslsites.com'
I set the Trusted Proxies in my index.php
Request::setTrustedProxies(array('sslsites.com'));
composer.json
"silex/silex": "1.0.*@dev",
"twig/twig": "~1.12",
"symfony/twig-bridge": "~2.2",
"symfony/validator": "~2.2",
"symfony/form": "~2.2",
"symfony/config": "~2.2",
"symfony/translation": "~2.2",
"symfony/locale": "~2.2",
"symfony/yaml": "~2.2",
"symfony/filesystem": "~2.2",
"symfony/finder": "~2.2",
"swiftmailer/swiftmailer": "~4.3",
"doctrine/dbal": "~2.3"
When running "url('category')" in a twig-Template, i'd expect:
https://sslsites.com/sitename.com/category
But I see instead
https://sslsites.com/category
I don't want a quick and dirty solution. Can anyone give me a hint?
When using the component as part of the framework you can the router.request_context.base_url
parameter, like so..
parameters:
router.request_context.base_url: my/path
Which would lead me to believe that you would be able to use..
if ($baseUrl = $app['request']->server->get('HTTP_X_FORWARDED_HOST')) {
$app['request_context']->setBaseUrl($baseUrl);
}
I assume the best place to do this would be when you are creating the app but I may be wrong as I've only had a cursory glance at Silex.