我觉得我觉得和大多数情况有点不同。 这与我之前遇到的任何情况都是完全不同的:
我正在为希望/需要保留对其规范域的完全控制权的客户build立一个网站。 他们不是简单地将www.theirdomain.com和theirdomain.com指向我的服务器IP,而是将stream量路由到他们,让他们的Big-IP设备通过client.mydomain.com将这些stream量发送给我们。 我不知道大IP,但我怀疑/假设这是一个重写,用户将只能看到他们的theirdomain.com 。
另外,客户端有两个子域名,他们的login页面将由我的应用程序提供,他们的信息系统团队不希望与他们有任何关系。 他们只是更新这些域的DNS指向我的服务器。 但是,login页面在client.mydomain.com/path/to/landing/page 。
因为我们不希望最终用户看到client.mydomain.com ,但是,我正常的301redirect到回答URL的过程似乎会产生一些不必要的stream量:
sub.theirdomain.com的请求 www.theirdomain.com/path/to/landing/page 在第2步中,我可以简单地将url重写为www.theirdomain.com并直接提供内容,而不必redirect到设备上。 更好的想法也欢迎。 正如我所说,这不是我以前遇到的,我正在寻找的select。
我们有几个客户端已经build立,所以他们保留对自己的DNS的控制权,因为他们中的一些只有子域指向我们。 我们使用nginx作为一个负载平衡器,也处理redirect,我们有我们的redirect在默认的虚拟主机文件(00default)。 没什么太复杂的,对我们来说效果还不错:
if ($host ~* "^ourdomain.com$") { rewrite ^(.*)$ http://www.ourdomain.com$1 permanent; } if ($host ~* "^subdomain.otherdomain.com$") { rewrite ^(.*)$ https://ourdomain.com$1 permanent; } if ($uri !~* (/option/.*|/simple/.*|/embed/.*|/mini/.*|/someOtherOption\.action.*|/otherOption\.action.*|/file/[0-9a-zA-Z]+/html5.*|/file/[0-9a-zA-Z]+/html5mobile.*|/thumbnail/.*) ) { set $cname_match "N"; } if ($host !~* "(.*\.)?ourdomain\.com|videos\.yetanotherdomain\.com") { set $cname_match "${cname_match}N"; } if ($cname_match = "NN") { rewrite ^.*$ http://www.ourdomain.com/; } if ($uri !~* (/thumbnail_.*|/vcomments/.*|/onethmb.gif$|/crossdomain.xml$|/otherthmb[0-9]+.gif$)) { set $thumb_redirect "Y"; } if ($host ~* "^(cdn-)?thumbs\.ourdomain\.com") { set $thumb_redirect "${thumb_redirect}Y"; } if ($thumb_redirect = "YY") { rewrite ^.*$ http://www.ourdomain.com/ permanent; } location / { proxy_pass http://ourdomain_apache_pool; error_page 404 @fallback404; error_page 403 @fallback403; } # redirects location /learn-more { rewrite /learn-more/? http://www.ourdomain.com/features permanent; } # help location ~* ^/help/zendesk/*.*$ { proxy_pass http://ourdomain_ruby_pool; } location ~* ^/help/*.* { rewrite ^/(.*) http://support.ourdomain.com permanent; }
在我看来,你可以采取上述重写规则之一,如:
if ($host ~* "^subdomain.otherdomain.com$") { rewrite ^(.*)$ https://ourdomain.com$1 permanent; }
只要让他们把DNS指向你的服务器的域名,然后按照你的意愿重写。