Remotely viewing web pages served by pow.cx

早过忘川 提交于 2019-12-18 11:27:33

问题


Using WEBrick you could navigate to an app you were serving from another device/virtual machine by navigating to your.ip.address.here:port

Is it possible to do something similar with pow.cx?


回答1:


Specifically, no, because Pow uses the Host header of the request to determine which app you need to access. To get that working remotely, you would have to have the remote machine map the required domain name to your IP address - either with a local DNS server or by editing the HOSTS file. Both of which are possible but annoying.

The simplest thing to do in that case is to start up a standalone Rails server as you mentioned (using ./script/server or rails s depending on the version), and then you can address http://[ip address]:3000 as before.

In other words, Pow works because it intercepts your local domain resolution, something that isn't affected by (or available to) remote machines.




回答2:


The latest version of Pow (0.4.0) now includes xip.io support. You can read about the release here.

Here's a quick explanation of how this helps Pow serve your Rails apps across your entire local network, from their post:

Say your development computer’s LAN IP address is 10.0.0.1. With the new version of Pow, you can now access your app at http://myapp.10.0.0.1.xip.io/. And xip.io supports wildcard DNS, so any and all subdomains of 10.0.0.1.xip.io resolve too.

Here's a description of xip.io, from their site:

xip.io runs a custom DNS server on the public Internet. When your computer looks up a xip.io domain, the xip.io DNS server extracts the IP address from the domain and sends it back in the response.




回答3:


There are basically two options:

  • Don't use pow: run your applications on localhost as usual and access them as usual
  • Edit the hosts file (or local DNS) to point your server machine ip

Example accessing from a virtual windows machine: Suppose you are running two rails applications in pow: store.dev and auth.dev, and you want to access them from a windows xp virtual machine to test them with IE, you only need to edit your hosts file to add the lines:

C:\WINDOWS\system32\drivers\etc\hosts

# Allow to access applications in pow. 
# The ip address points to the host machine localhost, that usually is the default gateway
10.0.2.2      store.dev
10.0.2.2      auth.dev

And then open the IE browser to access your applications in http://store.dev and http://auth.dev respectivelly.



来源:https://stackoverflow.com/questions/6379453/remotely-viewing-web-pages-served-by-pow-cx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!