开发者

Using Phusion Passenger on a development local area network

I have setup phusion passenger on my development server.

<VirtualHost *:80>
  ServerName railscasts.local
  DocumentRoot "/Users/rb开发者_运维技巧ates/code/railscasts/public"
  RailsEnv development
  RailsAllowModRewrite off
  <directory "/Users/rbates/code/railscasts/public">
    Order allow,deny
    Allow from all
  </directory>
</VirtualHost>

I would like to access my rails application from other machines on the network, but i would prefer not to have to configure my hosts file for each machine i want to access it from.

127.0.0.1 railscasts.local

From my understanding, i could setup a local DNS server which would solve the problem, but, again, i would prefer not to have to do that. I tried setting ServerName to the ip address of my development server, but this didn't work, it just failed silently.

Is there anyway to accomplish this other than a DNS Server, or configuring every machine on the LAN? Should i be able to achieve it by specifying an ip address?

Thanks


You could either use IP based virtual hosting in Apache, assigning each app to its own IP address, or, use different ports.

I'm assuming you have more than one app in development because otherwise an even easier solution would be simply to make this vhost the default one.

Setting up IP and/or Port based vhosting is straightforward enough. You just need to Listen [1] to the relevant IPs / Ports and then use the ip.address:port in the VirtualHost container as per your example above.

[1] http://httpd.apache.org/docs/current/mod/mpm_common.html#listen


I've been looking at how to do this for a few days. I've found a good starting point, but I'm sure it could be improved.

Change the top of your vhost to:

Listen 1234
<VirtualHost *:1234>

You can use any port number you like as long as its not in use.

You can access your app by visiting yourcomputername.local:1234 in the browser of another computer on the network.

Caveats:

This seems to stop you accessing your app by the name you defined (myapp.local). I'm looking in to whether you can do both from the same vhost.

There's probably a better way to access the app over the network with something like yourcomputername.local/myapp and myapp.local on the machine running the app.

Would love to hear suggestions on improving this solution

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜