简体   繁体   English

如何访问无业游民的访客服务器名?

[英]How to access vagrant guest servername?

I installed Vagrant,set up vagrant box as per the tutorial of the site Hashicorp, i have set up the port forwarding, the private network with a unique IP, and folder syncing. 我按照网站Hashicorp的教程安装了Vagrant,设置了vagrant框,我已经设置了端口转发,具有唯一IP的专用网络以及文件夹同步。

Here is what I have when I SSH in : 这是我使用SSH时拥有的:

login as: vagrant
vagrant@127.0.0.1's password:
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-101-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Wed Nov 30 10:35:39 UTC 2016

  System load:  0.22              Processes:           86
  Usage of /:   3.7% of 39.34GB   Users logged in:     0
  Memory usage: 25%               IP address for eth0: 10.0.2.15
  Swap usage:   0%                IP address for eth1: 192.168.33.10

The vagrant file is in C:\\vagrant2 (Windows 10) 流浪者文件位于C:\\ vagrant2(Windows 10)中

I have two folders that containt index.html file. 我有两个包含index.html文件的文件夹。

The var/www/html is synced with C:\\vagrant2\\html folder in the host (by default), i added another folder The var/www/html2 is synced with C:\\vagrant2\\html2 folder in the host var / www / html与主机中的C:\\ vagrant2 \\ html文件夹同步(默认情况下),我添加了另一个文件夹var / www / html2与主机中的C:\\ vagrant2 \\ html2文件夹同步

the vagrant file is like this : 流浪者文件是这样的:

Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.synced_folder "./html2", "/var/www/html2", :mount_options => ["dmode=777", "fmode=644"]
config.vm.provision :shell, path: "bootstrap.sh"
config.vm.network :forwarded_port, guest: 80, host: 4567
config.vm.network "public_network", ip: "192.168.33.10"

in the guest the /etc/hosts file is like this (I defined 2 hosts): 在来宾中,/ etc / hosts文件是这样的(我定义了2个主机):

127.0.0.1 localhost
192.168.33.10 box.local
127.0.0.1 bebox.local
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

the Apache configuration file is like this : Apache配置文件如下所示:

Listen 81
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ServerName box.local
</VirtualHost>

<VirtualHost *:81>
    DocumentRoot /var/www/html2
    ServerName bebox.local
    ServerAlias bebox
</VirtualHost>

I can access the pages via the ip address forwarding : http://127.0.0.1:4567/ 我可以通过ip地址转发访问页面: http : //127.0.0.1 : 4567/

i can access the same site with its IP : 192.168.33.10 我可以使用其IP地址访问同一站点:192.168.33.10

I can access the second site that is listening on port 81 : 192.168.33.10:81 我可以访问正在侦听端口81的第二个站点:192.168.33.10:81

However i need to access by the servername i defined in the guest. 但是,我需要通过在来宾中定义的服务器名进行访问。 I typed in my browser in Windows 10 : 我在Windows 10中输入了浏览器:

http://box.local HTTP://box.local

http://bebox.local HTTP://bebox.local

none of them work i have in Chrome console : 它们都无法在Chrome控制台中正常工作:

GET http://box.local/ net::ERR_NAME_NOT_RESOLVED

In guest operating system, when I ping box.local or bebox.local, it's okay. 在来宾操作系统中,当我ping box.local或bebox.local时,可以。

On host machine, pinging the names doesn't work, it says didn't find the host box.local however pinging even localhost does work 在主机上,对名称进行ping操作不起作用,它说没有找到主机box.local,但是即使本地主机也可以ping通

I tried disabling the Firewall of Windows, but doesn't change anything. 我尝试禁用Windows防火墙,但未做任何更改。

You need to modify the host file from your windows host machine (it should be at C:\\WINDOWS\\system32\\drivers\\etc\\hosts ) and add the following 您需要从Windows主机修改主机文件(该文件应位于C:\\WINDOWS\\system32\\drivers\\etc\\hosts )并添加以下内容

192.168.33.10    box.local
192.168.33.10    bebox.local

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM