kubesphere使用nginx代理登陆pod终端显示错误处理
部署版本:Kubernetes 1.17 Kubersphere 2.1.1
目前 Kubesphere 已经部署成功,但是直接从网页访问 terminal 终端的功能,提示:could not connect to the container。
对于 kubectl 终端
1、处理方式,需要配置nginx配置:
server { listen 80; include ssl-conf/ssl-full.loadttl.com.conf; server_name kubesphere.loadttl.com; access_log /var/log/nginx/access.log json; error_log /var/log/nginx/error.log; index index.html index.htm; if ($ssl_protocol = "") { return 301 https://$host$request_uri; } location / { proxy_http_version 1.1; proxy_pass http://10.10.10.120:30880; proxy_redirect off; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 3600s; proxy_read_timeout 3600s; proxy_send_timeout 3600s; send_timeout 3600s; } location /api/ { proxy_http_version 1.1; proxy_redirect off; proxy_pass http://10.10.10.120:30880; proxy_set_header Host $host:$server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /apis/monitoring.coreos.com/ { proxy_pass http://10.10.10.120:30880; proxy_redirect off; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 3600s; proxy_read_timeout 3600s; proxy_send_timeout 3600s; send_timeout 3600s; } location /api/v1/ { proxy_pass http://10.10.10.120:30880; # proxy_redirect off; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 3600s; proxy_read_timeout 3600s; proxy_send_timeout 3600s; send_timeout 3600s; } location /apis/storage.k8s.io { proxy_pass http://10.10.10.120:30880; proxy_redirect off; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 3600s; proxy_read_timeout 3600s; proxy_send_timeout 3600s; send_timeout 3600s; } location /apis/apps/v1/namespaces/ { proxy_http_version 1.1; proxy_pass http://10.10.10.120:30880; proxy_redirect off; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 3600s; proxy_read_timeout 3600s; proxy_send_timeout 3600s; send_timeout 3600s; } location /kapis/resources.kubesphere.io/v1alpha2/namespaces { proxy_http_version 1.1; proxy_pass http://10.10.10.120:30880; proxy_redirect off; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 3600s; proxy_read_timeout 3600s; proxy_send_timeout 3600s; } location /kapis/resources.kubesphere.io/ { proxy_http_version 1.1; proxy_redirect off; proxy_pass http://10.10.10.120:30880; proxy_set_header Host $host:$server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /apis/devops.kubesphere.io/ { proxy_http_version 1.1; proxy_pass http://10.10.10.120:30880; proxy_redirect off; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 3600s; proxy_read_timeout 3600s; proxy_send_timeout 3600s; send_timeout 3600s; } location /apis/apps/v1/ { proxy_http_version 1.1; proxy_redirect off; proxy_pass http://10.10.10.120:30880; proxy_set_header Host $host:$server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /apis/ { proxy_http_version 1.1; proxy_redirect off; proxy_pass http://10.10.10.120:30880; proxy_set_header Host $host:$server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /api/v1/watch/namespaces { proxy_pass http://10.10.10.120:30880; proxy_set_header Host $host:$server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /kapis/terminal.kubesphere.io/ { proxy_http_version 1.1; proxy_redirect off; proxy_pass http://10.10.10.120:30880; proxy_set_header Host $host:$server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
2、检查nginx配置,并加载配置
/usr/local/nginx/sbin/nginx -t /usr/local/nginx/sbin/nginx -s reload
3、再次查看功能
做一个决定,并不难,难的是付诸行动,并且坚持到底。