1

I have this configuration:

  • The Amazon Elastic Load Balancer (ELB) routes port 80 to port 81 and port 443 to port 80
    • The cert is handled in ELB
  • Nginx listens to port 80 and 81
    • Port 81 redirects to https
    • Port 80 is the main server

The nginx server block for port 81:

server {
    listen 81 default_server;
    listen [::]:81 default_server;
    server_name _;
    return 301 https://$host$request_uri;
}

The problem is that http requests timeout (408). Suggestions?

Pothi Kalimuthu
  • 5,734
  • 2
  • 24
  • 37
ic3b3rg
  • 111
  • 4
  • Always? Occasionally? – Michael - sqlbot Dec 02 '16 at 13:08
  • Always - doesn't seem to be listening to port 81. – ic3b3rg Dec 04 '16 at 07:30
  • Well, you do need port 81 open in the security group on the instance... but error 408 Request Timeout means the server timed out waiting for the client. 504 Gateway Timeout would be the opposite error, and more sensible if this were the problem. Can you capture the response headers? – Michael - sqlbot Dec 04 '16 at 12:27
  • 1
    Simpler solution: port 80 listener issues the redirect if `$http_x_forwarded_proto` isn't set to the string `https`, because ELB will set that for each request if the client connection uses HTTPS. – Michael - sqlbot Dec 04 '16 at 12:30
  • @Michael-sqlbot - Thanks - that's the workaround I ended up using. – ic3b3rg Dec 05 '16 at 05:51

0 Answers0