English 中文(简体)
How can i see my apache rails server from other computers on my local network?
原标题:

I have an apache server running, with mongrels underneath running rails. The apache config file for my rails app looks like this:

<VirtualHost *:80>
  ServerName trunk.production.charanga
  ServerAlias max.trunk.production.charanga

  DocumentRoot /home/max/work/e_learning_resource/trunk/public

  RewriteEngine On

  <Proxy balancer://mongrel1>
    BalancerMember http://127.0.0.1:5010
  </Proxy>

  # Redirect all non-static requests to thin
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://mongrel1%{REQUEST_URI} [P,QSA,L]

  ProxyPass / balancer://mongrel1/
  ProxyPassReverse / balancer://mongrel1/
  ProxyPreserveHost on

  <Proxy *>
    Order deny,allow
    Allow from all
  </Proxy>

  # Custom log file locations
  ErrorLog  /home/max/work/e_learning_resource/trunk/log/error.log
  CustomLog /home/max/work/e_learning_resource/trunk/log/access.log combined

</VirtualHost>

I thought that this would let me access it from another computer with max.trunk.production.charanga, but there s another step i m sure, that i can t figure out. At the moment, if i type my ip address into the address bar in firefox on another computer, i see the default apache server (with "It works!" etc), but i can t get to my rails apache server. Please correct me if i m using the wrong terminology here...

thanks max

问题回答

The computer attempting to access it needs to know how to resolve the DNS entry max.trunk.production.charanga to the correct IP address 192.168.1.42 (or whatever is the IP address of your server). It cannot figure this out without being told.

You can usually tell it this information by editing /etc/hosts and pointing that address to the correct IP address. Just simply having Apache recognize the name doesn t allow your other machines to know how to access it.

Alternatively, if you run a local DNS service, you can add an entry there.

Editing of your hosts file is a quick and easy solution.

Adding the line

192.168.1.1    trunk.production.charanga max.trunk.production.charanga

to it will tell your computer to use that ip for that domain. Depending on your browser (Firefox does caching internaly) or your OS (windows caches as well), you may need to restart your browser or flush your dns cache.

For more information about your hosts file (including where to find it on different OSes), check this wikipedia link.

I think it just simple,

I always do like this. example . 200.100.10.1:3000/ . I access my friend web application in another city.

or

<VirtualHost>
DocumentRoot /htdoc/trunk/ <-- this is my app path. I move my rails app into xampp for exp
ServerName 200.100.10.1:3000
ServerAlias 200.100.10.1
</VirtualHost>

so I just type 200.100.10.1 to access their application if i m not wrong. I hope it work

I found the answer: the solution is to make the required server the default server for my ip address. I did this by changing the top of the config file for the required site (/etc/apache2/sites-available/001-trunk in this case)

from this

<VirtualHost *:80>
  ServerName trunk.charanga
  ServerAlias max.trunk.charanga

  DocumentRoot /home/max/work/e_learning_resource/trunk/public
  ......etc

to

NameVirtualHost 192.168.0.234:80
<VirtualHost 192.168.0.234:80>
  ServerName trunk.charanga
  ServerAlias max.trunk.charanga

  DocumentRoot /home/max/work/e_learning_resource/trunk/public
  .....etc

where 192.168.0.234 is my network ip address.

Now, when someone else enters that ip in a browser they get the site i want them to get instead of the apache default site.

Thanks everyone for your advice!

type in the ip and port like so:

127.0.0.0:80/rails

this will only work if permissions are set to read/write.





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签