如何从native ip 127.0.0.1访问vagrant中的服务?

时间:2017-06-05 10:49:50

标签: vagrant ip openstack dashboard devstack

使用Vagrant安装devstack。在安装配置之前将HOST_IP设置为127.0.0.1。完成安装后,它告诉使用这些信息访问web ui:

=========================
DevStack Component Timing
=========================
Total runtime    3523

run_process      113
test_with_retry    7
pip_install      647
wait_for_service  51
yum_install      338
git_timed        853
=========================



This is your host IP address: 127.0.0.1
This is your host IPv6 address: ::1
Horizon is now available at http://127.0.0.1/dashboard
Keystone is serving at http://127.0.0.1/identity/
The default users are: admin and demo
The password: secret
Services are running under systemd unit files.
For more information see:
https://docs.openstack.org/developer/devstack/systemd.html

我使用private_ip在Vagrantfile中设置192.168.33.11,我尝试这种方式来访问网络ui:

http://192.168.33.11/dashboard

但不行。因此,我在Vagrant中测试使用curl可以确认一些事情:

[stack@localhost devstack]$ curl -I http://127.0.0.1/dashboard
HTTP/1.1 302 Found
Date: Mon, 05 Jun 2017 10:38:37 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips mod_wsgi/3.4 Python/2.7.5
Vary: Accept-Language,Cookie
X-Frame-Options: SAMEORIGIN
Content-Language: en
Location: http://127.0.0.1/dashboard/auth/login/?next=/dashboard/
Content-Type: text/html; charset=utf-8

现在如何访问仪表板?

2 个答案:

答案 0 :(得分:1)

这不起作用,因为devstack在您的VM上运行在127.0.0.1上。

您可以更改配置文件中的HOST_IP变量(在localrc部分下 - 请参阅https://docs.openstack.org/developer/devstack/configuration.html)并使用您从Vagrantfile设置的静态IP

HOST_IP=192.168.33.11
SERVICE_HOST=$HOST_IP

答案 1 :(得分:0)

这种方式有效:

list2 = [0,0,0,1,1,1,1,1,2,2,2,2,3,4,4,5,5]

来自浏览器:

http://localhost:8080/dashboard

参考

$ ssh -L 8080:localhost:80 vagrant@192.168.33.11