SSL port for Azure Web Site using node.js?

放肆的年华 提交于 2019-12-11 01:59:55

问题


I'm having difficulty getting a node.js app deployed as an Azure Web Site to listen on the appropriate port for SSL (within the Azure environment).

Serving up SSL requests in any other environment where I have control over the port is no problem and working fine. I don't believe this to be an issue with the app code (using Express, FYI).

Azure Web Sites seem to forward port 80 traffic from the load balancer to whatever port is available, which is set in the process.env.PORT variable.

I don't see any relevant equivalent within process.env for SSL traffic, despite having successfully loaded a cert into the Azure portal for the given Web Site and configured its bindings.

My question is this: how can I configure Azure to spit out the requisite file descriptor for traffic on port 443?

I've read a little on how to configure a worker in a Cloud Service here, but it doesn't seem applicable for a Web Site.

For reference, when I attempt to listen on either 443 or process.env.PORT, I get the following error:

Application has thrown an uncaught exception and is terminated:
Error: listen EACCES
    at errnoException (net.js:901:11)
    at Server._listen2 (net.js:1039:14)
    at listen (net.js:1061:10)
    at Server.listen (net.js:1127:5)

回答1:


I assume you've read http://www.windowsazure.com/en-us/develop/net/common-tasks/enable-ssl/‎

If I understand it correctly, Azure will do the https termination for you. Your app/service still gets http traffic.

Regardless, you still need to listen on process.env.PORT. Always. And will always get http traffic there (not https). If the original client used port 80, Azure will just do a pass-thru to you. If the client used 443, Azure will terminate the https and open an http request to you.



来源:https://stackoverflow.com/questions/19106899/ssl-port-for-azure-web-site-using-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!