如何将 CNAME 指向 OpenShift 路由
How to point a CNAME to an OpenShift route
我在 OpenShift 上托管的应用程序有一个 URL 看起来像这样的路由:
https://books-student-book-reservation-backend-project.apps.amarige.hostname.us
我想给最终用户一个 URL,看起来像这样:https://breeze.us。首先它隐藏了 OpenShift URL 结构,其次它更容易记住。归根结底,它对用户更友好。
挑战在于,当我将 breeze.us 重定向到 OpenShift 路由时,我从 OpenShift 收到“应用程序不可用”错误。
关于如何解决这个问题有什么建议吗?
如果您使用的是 OpenShift Online
在 OpenShift Online Starter 中,不允许自定义主机名。您可以购买 OpenShift Online Pro(允许设置自定义主机名),或使用反向代理将您的流量(从具有自定义主机名的另一台服务器)重定向到 OpenShift。
如果您使用的是自行部署的 OKD
您可以像这样为您的路由设置自定义主机名:
# A example unsecured route with custom hostname
apiVersion: v1
kind: Route
metadata:
name: route-unsecured
spec:
host: www.your-custom-hostname.com # here
to:
kind: Service
name: service-name
如果您需要在同一主机名下提供多个路由,您也可以使用自定义主机名进行基于路径的路由:
# A example unsecured path-based route with custom hostname
apiVersion: v1
kind: Route
metadata:
name: route-unsecured
spec:
host: www.your-custom-hostname.com
path: "/test" # here
to:
kind: Service
name: service-name
以便您可以使用 www.your-custom-hostname.com/test
访问您的路线。
我在 OpenShift 上托管的应用程序有一个 URL 看起来像这样的路由:
https://books-student-book-reservation-backend-project.apps.amarige.hostname.us
我想给最终用户一个 URL,看起来像这样:https://breeze.us。首先它隐藏了 OpenShift URL 结构,其次它更容易记住。归根结底,它对用户更友好。
挑战在于,当我将 breeze.us 重定向到 OpenShift 路由时,我从 OpenShift 收到“应用程序不可用”错误。
关于如何解决这个问题有什么建议吗?
如果您使用的是 OpenShift Online
在 OpenShift Online Starter 中,不允许自定义主机名。您可以购买 OpenShift Online Pro(允许设置自定义主机名),或使用反向代理将您的流量(从具有自定义主机名的另一台服务器)重定向到 OpenShift。
如果您使用的是自行部署的 OKD
您可以像这样为您的路由设置自定义主机名:
# A example unsecured route with custom hostname
apiVersion: v1
kind: Route
metadata:
name: route-unsecured
spec:
host: www.your-custom-hostname.com # here
to:
kind: Service
name: service-name
如果您需要在同一主机名下提供多个路由,您也可以使用自定义主机名进行基于路径的路由:
# A example unsecured path-based route with custom hostname
apiVersion: v1
kind: Route
metadata:
name: route-unsecured
spec:
host: www.your-custom-hostname.com
path: "/test" # here
to:
kind: Service
name: service-name
以便您可以使用 www.your-custom-hostname.com/test
访问您的路线。