Invalid ports added in redirects on AWS EC2 nginx
mdounin at mdounin.ru
Mon Jun 2 15:32:02 UTC 2014
On Sun, Jun 01, 2014 at 01:48:09PM -0400, allang wrote:
> On AWS, I'm trying to migrate a PHP Symfony app running on nginx. I want to
> be able to test the app by directly talking to the EC2 server and via an
> Elastic Load Balancer (ELB -the public route in).
> I've setup the ELB to decrypt all the SSL traffic and pass this on to my EC2
> server via port 80, as well as pass port 80 directly onto my EC2 server via
> port 80.
> Initially this caused infinite redirects in my app but I researched and then
> fixed this by adding
> fastcgi_param HTTPS $https;
> with some custom logic that looks at $http_x_forwarded_proto to figure out
> when its actually via SSL.
> There remains one issue I can't solve. When a user logs into the Symfony
> app, if they come via the ELB, the form POST eventually returns a redirect
> back to https://elb.mysite.com:80/dashboard instead of
> https://elb.mysite.com/dashboard which gives the user an error of "SSL
> connection error".
> I've tried setting
> fastcgi_param SERVER_PORT $fastcgi_port;
> to force it away from 80 and I've also added the
> fastcgi_param HTTPS $fastcgi_https;
> # fastcgi_param SERVER_PORT $fastcgi_port;
> #fastcgi_index index.php;
> fastcgi_param SCRIPT_FILENAME
> include fastcgi_params;
Make sure you've commented out SERVER_PORT from the fastcgi_params
More information about the nginx