1

Hey everyone so I configured my ELB to use an SSL certificate and it works great, however, I still have a problem where if a user comes to my website on port 80 under HTTP the website does not redirect them to an HTTPS secure connection. Heres a screenshot of my ELB configuration as seen in the Elastic Beanstalk configuration tab. Any help is appreciated thank you. elb config

4 Answers 4

1

It wasn't the elb at all I simply had to add this code:

if (process.env.NODE_ENV === "production" || process.env.NODE_ENV === "awsDevelopmentServer") {
  app.use(function(req, res, next) {
    // Insecure request?
    if (req.get("x-forwarded-proto") == "http") {
      // Redirect to https://
      return res.redirect("https://" + req.get("host") + req.url);
    }```
Sign up to request clarification or add additional context in comments.

1 Comment

Looks like that form is best practice according to amazon: aws.amazon.com/premiumsupport/knowledge-center/…
1

While it seems like you got it working by redirecting in your application, it is possible to do this redirect entirely in your ALB. Documentation: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html

This feature was released in July 2018. https://aws.amazon.com/about-aws/whats-new/2018/07/elastic-load-balancing-announces-support-for-redirects-and-fixed-responses-for-application-load-balancer/

Elastic Beanstalk may not have launched their own support to configure this. You may be able to configure it via ebextensions, but for now it may be best to just do it in your application.

Comments

0

You can set up Application Load Balancer listener in the following way:

HTTP 80: default action 
IF 
Requests otherwise not routed
THEN 
Redirect to HTTPS://#{host}:443/#{path}?#{query}
Status code:HTTP_301

Comments

0

In fact, you can no longer do it from the Elastic Beanstalk interface.

Also don't do it from the app, bad solution for load.

You must now go to the EC2 load balancer and change the listener to port 80, as described here:

https://medium.com/@j_cunanan05/how-to-redirect-http-to-https-in-amazon-web-services-aws-elastic-beanstalk-67f309734e81

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.