[英]Kubernetes Nginx port 80 not available on public ip address (only private address)
我在 nginx_service.yaml 中有这个
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
tier: backend
spec:
selector:
app: nginx
tier: backend
ports:
- protocol: TCP
port: 80
externalIPs:
- 51.159.171.84
这在 nginx_deployment.yaml
...
containers:
- name: nginx
image: nginx:1.18.0
ports:
- containerPort: 80
在显示服务时,我可以看到外部 ip:
kubectl get services -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2d2h <none>
nginx ClusterIP 10.111.105.46 51.159.171.84 80/TCP 2d app=nginx,tier=backend
php ClusterIP 10.108.10.193 <none> 9000/TCP 2d1h app=php,tier=backend
但是,从浏览器: http://51.159.171.84显示连接被拒绝。 与 curl 相同:
curl http://51.159.171.84
curl: (7) Failed to connect to 51.159.171.84 port 80: Connection refused
但是通过使用 curl 和私有 IP,它可以工作:
curl 10.111.105.46
如何使 nginx 服务接受公共 ip 地址上的连接?
主机上的 80 端口是否打开? 如果没有启用它 sudo ufw allow 80/tcp。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.