This week we upgraded our Control Panel to the latest Symfony2 code. The upgrade went fairly smooth but some things broke. One of them was the generateUrl() method that creates a link to be used in your templates/controllers.

Our code looks like this:

$link = $this->generateUrl(‘route_name’, array(‘id’ => $id), true);

This should generate a link to https://example.com/route/$id but after the upgrade the link appeared as http://example.com:443/route/$id

This of course, does not work. Now, we use nginx (a very fast HTTP server) so it was perfectly possible that we were missing some configuration and that Symfony2 got confused. Thanks to jmikola for his answer on IRC, we quickly found the solution, add to nginx fcgi params the following line:

fastcgi_param HTTPS on;

This is needed because Symfony2 relies on this variable, passed by the web server to PHP, to generate the correct URL. Apache does this by default, but nginx needs this special config.