简体   繁体   English

如何禁用 http 使用 Kube.netes Nginx ingress controller 访问服务?

[英]How to disable http access to service using Kubernetes Nginx ingress controller?

I have a service providing an API that I want to only be accessible over https .我有一项提供 API 的服务,我希望只能通过https访问该服务。 I don't want http to redirect to https because that will expose credentials and the caller won't notice.我不希望http重定向到https ,因为这会暴露凭据并且调用者不会注意到。 Better to get an error response.最好得到错误响应。

How to do I configure my ingress.yaml?如何配置我的 ingress.yaml? Note that I want to maintain the default 308 redirect from http to https for other services in the same cluster.请注意,对于同一集群中的其他服务,我想保留从httphttps的默认 308 重定向。

Thanks.谢谢。

In the documentation : you can read the following sentence about HTTPS enforcement through redirect:文档中:您可以阅读以下关于 HTTPS enforcement through redirect 的句子:

By default the controller redirects (308) to HTTPS if TLS is enabled for that ingress.默认情况下,如果为该入口启用了 TLS,则 controller 会重定向 (308) 到 HTTPS。 If you want to disable this behavior globally, you can use ssl-redirect: "false" in the NGINX ConfigMap .如果要全局禁用此行为,可以在 NGINX ConfigMap中使用ssl-redirect: "false"

To configure this feature for specific ingress resources, you can use the nginx.ingress.kube.netes.io/ssl-redirect: "false" annotation in the particular resource.要为特定入口资源配置此功能,您可以在特定资源中使用 nginx.ingress.kube.netes.io/ssl-redirect: "false" 注释。

You can also create two separate configurations: one with http and https and the other one only for http.您还可以创建两个单独的配置:一个用于 http 和 https,另一个仅用于 http。

Using kube.netes.io/ingress.class annotation you can choose the ingress controller to be used.使用kube.netes.io/ingress.class注释,您可以选择要使用的入口 controller。

This mechanism also provides users the ability to run multiple NGINX ingress controllers (eg one which serves public traffic, one which serves "internal" traffic).该机制还为用户提供了运行多个NGINX 入口控制器的能力(例如,一个服务于公共流量,一个服务于“内部”流量)。

See also this and this similar questions.另见这个这个类似的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过 http 使用 nginx-ingress 的 Microk8s 仪表板无法正常工作(错误:`版本“extensions/v1beta1”中的类型“Ingress”不匹配`) - Microk8s dashboard using nginx-ingress via http not working (Error: `no matches for kind "Ingress" in version "extensions/v1beta1"`) 使用Node-RED作为Kubernetes中的服务的HTTP端点路由 - HTTP Endpoint routing using Node-RED as a service in Kubernetes GCP 外部 HTTP 云负载均衡器与 GKE 上的 nginx-ingress - GCP external HTTP Cloud Load Balancer with nginx-ingress on GKE 如何将nginx HTTP状态代码(在访问日志中)传递给php。 - How to pass nginx HTTP status codes (in access logs) to php. 如何使用“http”访问 WebApi? - How to access WebApi using "http"? 如何从服务读取控制器内部$ http请求的数据? - How to read data of $http request inside controller from a service? 如何在服务中进行http调用但得到控制器响应? AngularJS - How to make http call in service but get response by the controller? AngularJS 如何访问 Spring MVC REST 控制器中的 HTTP 标头信息? - How to get access to HTTP header information in Spring MVC REST controller? 如何在使用 NGINX 反向代理时将 HTTP 重定向到 HTTPS? - How to redirect HTTP to HTTPS while using an NGINX reverse proxy? 使用 Nginx 将 http 重定向到 https - redirect http to https by using Nginx
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM