use*_*644 1 macos portforwarding vagrant consul
我想使用 Vagrant 在我的本地机器(Mac OS X)上设置一个带有 UI 的 Consul 集群。到目前为止,我只是按照官方领事文档的入门说明进行操作:https : //www.consul.io/intro/getting-started/join.html
为了能够从主机访问 UI,我只是将这一行添加到提供的 Vagrantfile ( https://github.com/hashicorp/consul/blob/master/demo/vagrant-cluster/Vagrantfile )
n1.vm.network "forwarded_port", guest: 8500, host: 8500
Run Code Online (Sandbox Code Playgroud)
要在来宾机器上使用 UI 启动 Consul,我 ssh 进入机器,然后简单地将 -ui 标志添加到提供的命令中:
consul agent -server -bootstrap-expect=1 \
-data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 \
-enable-script-checks=true -config-dir=/etc/consul.d -ui
Run Code Online (Sandbox Code Playgroud)
Consul 启动时没有问题,从我可以执行的来宾机器开始:
curl -v 'http://localhost:8500/ui/'
Run Code Online (Sandbox Code Playgroud)
并返回预期的 HTML 页面。
但是,尝试http://localhost:8500/ui/在浏览器中访问或通过主机上的 curl访问不起作用。在主机上使用 curl 会导致:
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 8500 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8500 (#0)
> GET /ui/ HTTP/1.1
> Host: localhost:8500
> User-Agent: curl/7.54.0
> Accept: */*
>
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
Run Code Online (Sandbox Code Playgroud)
正确设置端口转发时我缺少什么?运行后的日志vagrant up对我来说很好:
n1: Forwarding ports...
n1: 8500 (guest) => 8500 (host) (adapter 1)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
745 次 |
| 最近记录: |