0

我在 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

有什么办法可以做到这一点?

4

1 回答 1

1

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

您可以在 nginx conf 文件中创建多个服务器块,该文件可以单独路由

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
        }
    }

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

于 2018-04-02T10:17:13.833 回答