【问题标题】:node server running on port 80 but cant call it by domain节点服务器在端口 80 上运行,但无法通过域调用它
【发布时间】:2018-11-24 21:18:08
【问题描述】:

我终于让我的 Angular5 服务器运行起来了。但是当我在端口 80 上启动它时,我无法通过 [domain].de 或 https://[domain].de 调用它;只有https://[domain].de:80 有效。 为什么会这样?

我通过这个命令启动服务器:

 ng serve --host [domain].de --port 80 --disable-host-check -ssl true --ssl-cert "/etc/letsencrypt/live/[domain].de/cert.pem" -ssl-key "/etc/letsencrypt/live/[domain].de/privkey.pem"

感谢您的帮助

【问题讨论】:

    标签: node.js angular ubuntu npm server


    【解决方案1】:

    您将 SSL 指定为 true,但也指定了端口 80。默认情况下,浏览器希望 https 位于端口 443 上,并且端口 80 未加密。

    如果您只指定主机名而不是方案,浏览器会假定您希望在端口 80 上建立未加密的连接。但您的端口 80 已加密。所以它失败了。

    如果您将https 指定为方案但未指定端口号,则浏览器会假定您要在端口 443 上连接。但您却在端口 80 上运行。所以连接失败。

    因此,如果您同时指定端口号和 https 作为方案,则您的 URL 仅在浏览器中有效。

    如果您不想指定端口号,最好的办法可能是使用端口 443。如果您仍想在端口 80 上应答,请在此处设置一些内容以重定向 https 方案.

    【讨论】:

    • 感谢 https://[domain].de 现在可以正常工作了。但只是 [domain].de 没有。我该如何解决?
    猜你喜欢
    • 2013-02-19
    • 2020-07-09
    • 2014-07-19
    • 2015-09-19
    • 1970-01-01
    • 2013-09-16
    • 2023-03-25
    • 2021-09-16
    • 1970-01-01
    相关资源
    最近更新 更多