【问题标题】:Redirect if hostname is incorrect with Node如果主机名与 Node 不正确,则重定向
【发布时间】:2016-06-12 20:01:38
【问题描述】:

我们在 IIS 上使用 http(端口 80)托管了一个站点 我们在 Node 上使用 https(端口 443)托管了一个新站点

由于我不会过多介绍的原因,我们不能使用 IISNode 在 IIS 上运行所有网站。

除非有人使用 https 访问 IIS 托管网站之一,否则此设置有效。

复制:

http://nameprintgraphics.com -> IIS 网站

https://npgcloud.com -> 节点网站

但是,如果您输入 https://nameprintgraphics.com,您将转到节点网站。我想防止这种行为。由于节点正在监听端口 443,有没有办法验证主机名,如果不正确,将用户重定向到 http。

我知道解决问题的方法有点复杂,但请与我一起寻找解决此问题的临时解决方案。 IISNode 正在阻止旧的 silverlight 应用程序在 IIS 中运行,原因我尚未确定。

【问题讨论】:

    标签: node.js redirect iis https


    【解决方案1】:

    为什么不在您的节点应用程序中检查req.headers.host,如果匹配,那么只需立即发送重定向响应?例如:

    // You may/may not want to append the `req.url` to the destination as well
    res.writeHead(302, { Location: 'http://nameprintgraphics.com' });
    res.end();
    

    【讨论】:

    • 我没有使用这种技术,因为它适用于多个网站,而不仅仅是 nameprintgraphics.com
    • 您是否尝试让 IIS 执行 SSL/TLS 终止,而只使用节点进程的反向 (http) 代理?
    猜你喜欢
    • 2014-01-13
    • 2016-12-29
    • 2011-10-24
    • 1970-01-01
    • 2021-03-28
    • 1970-01-01
    • 2016-09-20
    • 2016-02-28
    • 2019-10-25
    相关资源
    最近更新 更多