My config is as follows:

    server {
      listen *:80;
      server_name example.com;
      return 301 https://$host$request_uri;

  server {
      listen *:443 ssl;
      ssl_certificate /directory/of/cert/cert.pem;
      ssl_certificate_key /directory/of/cert/cert.pem;
      proxy_ssl_ciphers kEECDH+aRSA+AES:kRSA+AES:+AES256:!kEDH:!LOW:!EXP:!MD5:!aNULL:!eNULL;
      proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

      location / {
      proxy_pass http://localip:8080;

      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $http_connection;

However, when I curl -v to example.com, I get a time-out

curl -v http://host.example.com
* Rebuilt URL to: http://host.example.com/
*   Trying <public_ip>...
* connect to <public_ip> port 80 failed: Timed out
* Failed to connect to host.example.com port 80: Timed out
* Closing connection 0
curl: (7) Failed to connect to host.example.com port 80: Timed out

I've done some Googling and found this link: nginx redirect http to https not working

christofferp suggested that it could be the /sites-enabled/default config taking precedence and causing the problem, I've removed mine, but still having trouble.

I have tried a number of different config changes, but cannot seem to get it working.

Any ideas? Could it be something in my config that's wrong?

  • 1
    a timeout usually points toward a firewall problem. Apart from that, you've set example.com in your server config, but you try to connect to host.example.com. – Gerald Schneider Mar 25 '19 at 14:43
  • Damnit! It was the firewall, thanks Gerald. As I read your comment I realised I never opened HTTP. It's working now. – nielmarais Mar 25 '19 at 14:47

Thanks Gerald Schneider, I forgot to open HTTP on the firewall! Solved my problem.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.