acm regarded problem

0

I'm experiencing an issue with my Nginx web server on AWS where HTTP requests are not automatically redirecting to HTTPS, despite using ACM for SSL certificates. Can anyone advise on how to configure Nginx properly to enforce HTTPS redirection? i have enabled 443 port in security group i have tried to run dig command it seems ACM was added the correct configuration.

rajin
asked 6 days ago512 views
2 Answers
0
EXPERT
answered 6 days ago
profile picture
EXPERT
reviewed 6 days ago
  • Ensure your ALB Has a rule to redirect traffic from PORT 80 to 443

0

Hello,

Please try this solution.

Modifying your Nginx configuration to redirect HTTP traffic to HTTPS.

Step 1 Edit Nginx Configuration:

Use a text editor like Vi or Nano to open your Nginx configuration file. The location might vary, but it's typically /etc/nginx/nginx.conf or /etc/nginx/sites-available/<your_domain_name>.conf

sudo vi /etc/nginx/nginx.conf

Step 2 Modify Server Block:

Locate the server block for your website. This block should have lines defining server_name and potentially location /.

Step 3 Add Redirect Rule:

- If you only have one website, modify the `listen` directive within the server block:

  
   server {
       listen 80 443 ssl;  # Listen on both ports (HTTP and HTTPS)
       # ... other server block configuration ...
   }
   

 **Important:** Add `ssl` after port 443 to indicate an HTTPS connection.

Step 4 Save and Restart:

Save your changes (Ctrl+:+w+q+! followed by Enter in VI).

Restart Nginx to apply the new configuration

sudo systemctl restart nginx

https://stackoverflow.com/questions/54567333/redirecting-http-to-https-using-nginx-behind-aws-load-balancer

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuring-https-httpredirect.html

EXPERT
answered 6 days ago