skip to Main Content

I seem to have a problem with my nginx.

I just deployed a Flask app on an AWS EC2 instance and linked it to my subdomain (let’s call it subdomain.domain.com). Everything was working correctly, my app running on port 5001, I installed nginx to redirect traffic coming through port 80. And I did manage to do it. The problem came when I installed the let’s encrypt certificates using certbot.

I did not receive any error message, yet navigating to subdomain.domain.com was no longer doing anything apart from giving me a ERR_CONNECTION_TIMED_OUT.

I tried several things and check every configuration, recreated the certificates, restarted nginx service, but nothing worked. So I decided to start from scratch, uninstall nginx and reinstall it, but the problem persists.

For further information:

  • My EC2 instance accepts requests on port 80 and 5001.

  • nginx error log dos not show any error apart from an "aborting" message that just appeared right now
    enter image description here

  • nginx service status shows it’s active
    enter image description here

  • Right now I don’t have my site symlinked so I should not see it, but I should see Nginx Welcome page which is not the case

      server {
          listen 80;
          server_name subdomain.domain.com;
    
          location / {
              include proxy_params;
              proxy_pass http://<aws-private-ip>:5001;
          }
      }
    
  • UFW firewall shows as inactive, so I understand that is not the problem

  • I tried to kill all 80/tcp processes and restart nginx but it did not do a thing

  • I tried to use nginx -s reload but nothing changed

  • This my netstat plant on port 80 result
    enter image description here

  • The app is running and the server is indeed up, running and accessible since I can see the app opening subdomain.domain.com:5001 on my browser

Could someone point me towards other things I can try?

Thanks in advance

2

Answers


  1. Chosen as BEST ANSWER

    Ok, I managed to make nginx redirect to the app running on localhost on port 5001. The problem seemed to be due to default nginx file on sites-available somehow shadowing mine. Now I can navigate to my app using AWS's EC2 public IP address, but for some reason it is not showing the page when I navigate through the domain URL. I don't think it is related to AWS configuration since I have one inbound rule on my security grp allowing for connections from 0.0.0.0/0 on port 80 and I added a registry to my hosted zone for my_subdomain.mydomain.com pointing to the machine's public IP address.


  2. this worked fine for me- Please use this a reference.

    How To Install Nginx on Ubuntu 20.04

    See if you have the same steps done or missed a step.

    https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04#step-6-getting-familiar-with-important-nginx-files-and-directories

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search