【问题标题】:Detect if user uses proxypass in Apache or NodeJS检测用户是否在 Apache 或 NodeJS 中使用 proxypass
【发布时间】:2018-11-21 03:36:32
【问题描述】:

我开发了一个运行在端口 1234 上的 NodeJS 应用程序。为了在地址栏中不显示“:1234”,我使用了 proxypass/proxypassreverse,以便 URL 看起来像“mysite.com/myapp/”。

一切正常,但我的应用支持 SSO。当用户尝试访问“mysite.com/myapp”时,他被重定向到 SSO,他登录,然后 SSO 将他重定向到“mysite.com:1234”(因为 SSO 不知道有 proxypass )。

我在我的页面上创建了一个 javascript,检测 URL 中是否有“:1234”,如果有,window.location 将“:1234”替换为“/myapp”。

这对我来说不是一个很好的解决方案,我认为可能有一个 NodeJS 甚至更好的 Apache 解决方案来检测到达的 URL 是“:1234”还是“/myapp”。

提前致谢。

【问题讨论】:

    标签: node.js apache redirect proxypass


    【解决方案1】:

    好的,我的问题是 NodeJS 向 SSO 发送了带有端口号的 URL。我需要做的就是用我用于 ProxyPass 的字符串替换端口号:

    req.get('host').replace(':' + PORT, '/node')
    

    【讨论】:

      猜你喜欢
      • 2011-06-19
      • 2011-08-18
      • 1970-01-01
      • 2021-04-09
      • 2013-03-18
      • 2011-07-28
      • 2021-05-27
      • 2018-05-14
      • 2015-10-09
      相关资源
      最近更新 更多