如何在kubernetes群集中运行https安全应用程序
我想在kubernetes集群内通过https运行我的应用程序,并在集群外通过https公开它。我创建了如何在kubernetes群集中运行https安全应用程序,kubernetes,kubernetes-ingress,nginx-ingress,Kubernetes,Kubernetes Ingress,Nginx Ingress,我想在kubernetes集群内通过https运行我的应用程序,并在集群外通过https公开它。我创建了pod并公开了端口443。之后,我创建了一个ClusterIP服务,它连接到端口443上的pod,并公开端口443。最后,我创建了一个ingres,它连接到端口443上的服务。我使用GKE上的helm chart部署了所有这些资源。我使用NGINX入口控制器。你可以找到图表 当我通过https在集群内部访问应用程序时,它可以工作 curl https://my-nginx.https-app-
pod
并公开了端口443
。之后,我创建了一个ClusterIP
服务,它连接到端口443
上的pod,并公开端口443
。最后,我创建了一个ingres
,它连接到端口443
上的服务。我使用GKE上的helm chart部署了所有这些资源。我使用NGINX入口
控制器。你可以找到图表
当我通过https在集群内部访问应用程序时,它可以工作
curl https://my-nginx.https-app-64-production --cacert /etc/nginx/ssl/tls.crt
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
curlhttps://my-nginx.https-app-64-production --cacert/etc/nginx/ssl/tls.crt
欢迎来到nginx!
身体{
宽度:35em;
保证金:0自动;
字体系列:Tahoma、Verdana、Arial、无衬线字体;
}
欢迎来到nginx!
如果您看到此页面,则nginx web服务器已成功安装,并且
工作需要进一步配置
有关在线文档和支持,请参阅
.
商业支持可从以下网址获得:
感谢您使用nginx
但当我使用外部url访问它时,我会得到下面的错误
curl https://staging.vs-creator.iotcrawler.eu/
<html>
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
<hr><center>nginx/1.9.1</center>
</body>
</html>
curlhttps://staging.vs-creator.iotcrawler.eu/
400普通HTTP请求已发送到HTTPS端口
400错误请求
普通HTTP请求已发送到HTTPS端口
nginx/1.9.1
我不知道出了什么问题。我怀疑这与入口控制器配置有关。请在这方面帮助我。在ingress Resourcee中使用下面的注释
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
从
使用后端协议注释可以指示NGINX如何
应该与后端服务通信。(更换安全后端
在旧版本中)有效值:HTTP、HTTPS、GRPC、GRPC、AJP和
FCGI
默认情况下,NGINX在将请求转发到后端pod时使用
HTTP
,这导致400普通HTTP请求被发送到HTTPS端口
,因为后端pod需要HTTPS
请求。在ingress ResourceRece中使用下面的注释
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
从
使用后端协议注释可以指示NGINX如何
应该与后端服务通信。(更换安全后端
在旧版本中)有效值:HTTP、HTTPS、GRPC、GRPC、AJP和
FCGI
默认情况下,NGINX在将请求转发到后端pod时使用
HTTP
,这导致400普通HTTP请求被发送到HTTPS端口
,因为后端pod需要HTTPS
请求。您正在使用的入口控制器…是NGINX吗?是,nginx ingress您正在使用哪个ingress控制器…是nginx吗?是的,nginx ingress