Removing environment property to make the site work

0

Hello,

I have a question. I am running a node js / express web app on https through elastic beanstalk, code pipeline, and github. Under Instance traffic and scaling I've configured two Listeners in the console for 443 with listener protocol HTTPS, and 80 with listener protocol HTTP. In my application load balancer (found from my ec2 dashboard) under the Listeners and rules I've configured protocol:port HTTP:80 to redirect to HTTPS://... :443/.. etc. Also in my repository I uploaded the http to https redirect config file (specifically the one where you already define a 443 listener) found here.

I have two lines in my app.js file with const port = process.env.PORT and app.listen(port, ...) etc for the usual get-the-app-running-on-the-port.

What I noticed, though, was that when I define an environment property of PORT with value 443 under Configuration in the beanstalk environment, the site doesn't work. It throws a 502 Bad Gateway | nginx error. When I remove the environment property, the site works. It redirects and all.

Does the PORT 443 in the envir. properties not actually define the listener for https in elastic beanstalk? Is it rather the 443 under Listeners > Instance traffic and scaling ? If so, why? It seems that one is removing environment properties in order to make the site work.

1 回答
0

I think HTTPS can be used if the certificate is configured in the ALB as shown in the following document.
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuring-https-elb.html

profile picture
专家
已回答 10 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则