如何配置Homestead和xip.io? [英] How configure Homestead and xip.io?
问题描述
我想从其他设备(iPhone,Android设备等)访问我机器上宅基地上的站点.我的机器和所有设备都在同一网络上.
I want to access from other devices (iphone, android device, etc) to my sites on homestead in my machine. My machine and all device are on same network.
我想使用 http://xip.io ,但是我无法确定它.
I want to use http://xip.io but I could not confgure it.
我的IP机是192.168.0.12
My ip machine is 192.168.0.12
Homestead上站点的IP地址为192.168.10.10
The ip for sites on Homestead is 192.168.10.10
这是文件主机:
127.0.0.1 localhost
127.0.1.1 host
#Virtual Hosts on Homestead
192.168.10.10 siteOne.com
192.168.10.10 siteTwo.app
192.168.10.10 otherSite.app
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
这是Homestead.yaml
and this is Homestead.yaml
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Homestead-Projects
to: /home/vagrant/Homestead-Projects
sites:
- map: siteOne.com
to: /home/vagrant/Homestead-Projects/SiteOne/public
- map: siteTwo.app
to: /home/vagrant/Homestead-Projects/SiteTwo/public
- map: otherSite.app
to: /home/vagrant/Homestead-Projects/OtherSite/public
databases:
- homestead
- db_siteOne
- db_siteTwo
- db_otherSite
variables:
- key: APP_ENV
value: local
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 93000
# to: 9300
# - send: 7777
# to: 777
# protocol: udp
我该怎么办?
谢谢!
推荐答案
您可以通过浏览到http://<your_local_ip>.xip.io:8000
来访问您的网站.
You can access your site by browsing to http://<your_local_ip>.xip.io:8000
.
要了解其工作原理,您需要了解两个事实:
To understand how it works you need to know two facts:
- 域
example.your_ip.xip.io
解析为your_ip
. - 默认情况下,本地端口
8000
映射到您的宅基地虚拟机的端口80
.
- Domain
example.your_ip.xip.io
resolves toyour_ip
. - By default local port
8000
is mapped to port80
of your homestead virtual machine.
请注意,xip.io
充当"DNS",您无需编辑主机文件即可从本地网络上的其他设备访问您的宅基地.
Please note, xip.io
acts as a "DNS" and you don't need to edit your hosts file to access your homestead site from other devices on local network.
如果您仅在宅基地中映射了一个站点,则此解决方案将非常有效.如果有多个站点,则仅提供最后一个映射的站点.解决方法是在您的网址中使用网站标识符. http://<your_site>.<your_local_ip>.xip.io:8000
仍然解析为相同的端点,但是现在您可以更新homestead nginx来获取站点标识符并为正确的站点提供服务.
This solution works perfectly if you have only one site mapped in homestead. If there are multiple sites, only last mapped site gets served. A workaround is to use site identifier in your url. http://<your_site>.<your_local_ip>.xip.io:8000
still resolves to same endpoint but now you can update your homestead nginx to pickup the site identifier and serve the right site.
这篇关于如何配置Homestead和xip.io?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!