我有这种情况:
- 运行 Docker 容器的运行 Debian 的主机。
- 一个安装了CodeReady Containers (CRC)的 CentOS docker 容器。CRC 通过命令行在容器上工作,没有问题。
我想从主机访问(在容器文件中的https://console-openshift-console.apps-crc.testing
特定 IP 上)工作的 CRC Web 控制台。hosts
并且,应用于 Docker 容器,对以下内容进行更改haproxy.conf
:
global
log 127.0.0.1 local0
debug
defaults
log global
mode http
timeout connect 5000
timeout check 5000
timeout client 30000
timeout server 30000
frontend apps
bind CONTAINER_IP:80
bind CONTAINER_IP:443
option tcplog
mode tcp
default_backend apps
backend apps
mode tcp
balance roundrobin
option ssl-hello-chk
server webserver1 CRC_IP:6443 check
frontend api
bind CONTAINER_IP:6443
option tcplog
mode tcp
default_backend api
backend api
mode tcp
balance roundrobin
option ssl-hello-chk
server webserver1 CRC_IP:6443 check
为容器启用转发:
$ sysctl net.ipv4.conf.all.forwarding=1
$ sudo iptables -P FORWARD ACCEPT
并且还在代理后面启动 CRC:
$ crc config set http-proxy http://example.proxy.com:<port>
$ crc config set https-proxy http://example.proxy.com:<port>
$ crc config set no-proxy <comma-separated-no-proxy-entries>
https://console-openshift-console.apps-crc.testing
我可以成功地从主机调用 url (正确配置了dnsmasq 作为 DNS 解析器)!!!
但我收到此错误:
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {
},
"status": "Failure",
"message": "forbidden: User \"system:anonymous\" cannot get path \"/\"",
"reason": "Forbidden",
"details": {
},
"code": 403
}
笔记:
当 CRC 开始时,我有一个警告:
WARN Wildcard DNS resolution for apps-crc.testing does not appear to be working
即使尝试
oc
通过命令行在主机机器上使用 登录,也会失败并显示状态为“Forbidden”的错误消息:Error from server (InternalError): Internal error occurred: unexpected response: 403
。
问题出在哪里?我想不通。
对于那些感兴趣的人,这是项目在 GitHub 上的 Git 存储库。