如何实现到外部的重定向 url
How to Implement a redirect to an external url
动机:我们正在维护一个本地托管的网站 https://customerRelationsSite.com
此网站即将消失,我们想创建一个 URL 重定向到具有以下用例的其他网站
将 https://customerRelationsSite.com/eula/prodmanager?app=myapp 重定向到 domain.salesforce。com/eula/prod/myapp
或重定向https://customerRelationsSite.com/eula/prodmanager?app=myapp到domain.salesforce。com/eula/prod/myapp
同时将创建更多链接,这些链接将逐渐取代当前站点链接,即 https://customerRelationsSite.com/otherPaths, which will be redirected to other sites https://othersite/newPath 因此解决方案应该可配置以添加新的重定向
我们正在考虑以下选项:
- 在 AWS 上将 s3 存储桶创建为具有 url 重定向的网站,配置 cloudfront,r53 以 s3 作为源并将原始 DNS 条目 https://customerRelationsSite.com 指向 cloudfront
或
- 使用带有 ha-proxy 的 linux 框将 https://customerRelationsSite.com 重定向到新站点或路径
然后将原始 DNS 条目 https://customerRelationsSite.com 指向 ha-proxy
或
- 使用 linux deploy nginx 配置反向代理,然后将原始 DNS 条目 https://customerRelationsSite.com 指向 linux deploy nginx 框
这是我们对可能适用于上述用例的应用程序之一所做的;在 nginx.conf 我们创建了一个代理
location ~ ^/path/(?<section>.*) {
resolver 8.8.8.8;
proxy_pass https://othersite/newPath/$section$is$
}
location ~ ^/eula/prodmanager/(?<section>.*) {
resolver 8.8.8.8;
proxy_pass https://domain.salesforce.com/eula/prod/myapp/$section$is$
}
您会考虑哪些选项?
或者还有其他可用的最佳选择吗?
您可以使用静态 S3 存储桶执行此操作:
https://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html
正如您所说,只需将域指向(通过您喜欢的任何 DNS 方式)一个否则为空的 S3 存储桶,然后按照上面的说明设置重定向。
为了奖励积分,您也可以安装自定义 404 页面等:
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<ReplaceKeyWith>404.html</ReplaceKeyWith>
</Redirect>
</RoutingRule>
</RoutingRules>
这通常避免了托管 haproxy
个实例或 Linux 个实例的任何复杂性 - 并且具有成本效益并且 recommended by AWS themselves.
(顺便说一句 - 404 技巧非常适用于静态托管在 S3 存储桶中的单页应用程序。将所有 404 URL 重定向回 index.html
- 让 SPA 完成剩下的工作!)
动机:我们正在维护一个本地托管的网站 https://customerRelationsSite.com
此网站即将消失,我们想创建一个 URL 重定向到具有以下用例的其他网站
将 https://customerRelationsSite.com/eula/prodmanager?app=myapp 重定向到 domain.salesforce。com/eula/prod/myapp
或重定向https://customerRelationsSite.com/eula/prodmanager?app=myapp到domain.salesforce。com/eula/prod/myapp
同时将创建更多链接,这些链接将逐渐取代当前站点链接,即 https://customerRelationsSite.com/otherPaths, which will be redirected to other sites https://othersite/newPath 因此解决方案应该可配置以添加新的重定向
我们正在考虑以下选项:
- 在 AWS 上将 s3 存储桶创建为具有 url 重定向的网站,配置 cloudfront,r53 以 s3 作为源并将原始 DNS 条目 https://customerRelationsSite.com 指向 cloudfront
或
- 使用带有 ha-proxy 的 linux 框将 https://customerRelationsSite.com 重定向到新站点或路径 然后将原始 DNS 条目 https://customerRelationsSite.com 指向 ha-proxy
或
- 使用 linux deploy nginx 配置反向代理,然后将原始 DNS 条目 https://customerRelationsSite.com 指向 linux deploy nginx 框 这是我们对可能适用于上述用例的应用程序之一所做的;在 nginx.conf 我们创建了一个代理
location ~ ^/path/(?<section>.*) {
resolver 8.8.8.8;
proxy_pass https://othersite/newPath/$section$is$
}
location ~ ^/eula/prodmanager/(?<section>.*) {
resolver 8.8.8.8;
proxy_pass https://domain.salesforce.com/eula/prod/myapp/$section$is$
}
您会考虑哪些选项? 或者还有其他可用的最佳选择吗?
您可以使用静态 S3 存储桶执行此操作:
https://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html
正如您所说,只需将域指向(通过您喜欢的任何 DNS 方式)一个否则为空的 S3 存储桶,然后按照上面的说明设置重定向。
为了奖励积分,您也可以安装自定义 404 页面等:
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<ReplaceKeyWith>404.html</ReplaceKeyWith>
</Redirect>
</RoutingRule>
</RoutingRules>
这通常避免了托管 haproxy
个实例或 Linux 个实例的任何复杂性 - 并且具有成本效益并且 recommended by AWS themselves.
(顺便说一句 - 404 技巧非常适用于静态托管在 S3 存储桶中的单页应用程序。将所有 404 URL 重定向回 index.html
- 让 SPA 完成剩下的工作!)