【问题标题】:How to map webapp url to some custom url?如何将 webapp url 映射到一些自定义 url?
【发布时间】:2018-04-02 07:20:22
【问题描述】:

我在 Jboss EAP 7 服务器上部署了带有 REST API(使用 Spring 4)的 Angular JS Web 应用程序。对于每个客户,我都有这样的 Web 应用程序 URL:xyz.mydomain.com?clientId=12

但是,我的一些客户不希望我的域包含在 url 中。他们要么希望有自己的唯一 URL,例如 dummy.theredomain.com

或者至少他们希望在我的域前面有唯一的名称,例如 clientname.mydomain.com?clientId=12

有什么办法可以做到吗?

【问题讨论】:

  • 您需要购买域和子域,配置您的 nginx 以将域请求路由到您的服务器。如果您需要更清楚,我可以写一个答案。
  • 感谢您的评论。我有一些想法,但你仍然可以写作为答案。这将非常有帮助,在此先感谢。

标签: spring web-applications jboss url-routing cloaking


【解决方案1】:

要解决这个问题,您可以借助 nginx,购买您的域,然后在 nginx 中配置您的传入请求,以便任何服务器将其路由到您的后端系统。

你可以在你的 nginx 配置文件中创建多个服务器块,可以单独路由

server {
    server_name xyz.mydomain.com;
    # the rest of the config
    location / {
        proxy_pass http://localhost:9090
    }
}
server {
    server_name clientname.mydomain.com;
    location / {
        proxy_pass http://localhost:9090
    }
}

或者你可以有一个通配符匹配,它将所有子域请求重定向到你的后端服务器。

server{
        server_name mydomain.com  *.mydomain.com;
        # the rest of the config
        location / {
            proxy_pass http://localhost:9090
        }
    }

附注这种方法仅适用于您的域,这是非常简单的 nginx 配置,如果完全成熟,您必须探索更多才能使用,但它会让您了解如何解决您的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-13
    • 1970-01-01
    • 1970-01-01
    • 2011-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多