[英]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. 我有一个正在运行的apache服务器,在运行轨道的下面有杂乱的动物。 The apache config file for my rails app looks like this:
我的Rails应用程序的apache配置文件如下所示:
<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. 我以为这可以让我从具有max.trunk.production.charanga的另一台计算机上访问它,但是我确信还有另外一步,我不知道。 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.
此刻,如果我在另一台计算机上的Firefox的地址栏中键入我的IP地址,我会看到默认的Apache服务器(带有“ It works!”等),但是我无法进入Rails apache服务器。 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). 尝试访问它的计算机需要知道如何将DNS条目
max.trunk.production.charanga
为正确的IP地址192.168.1.42
(或服务器的IP地址)。 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. 通常,您可以通过编辑
/etc/hosts
并将其指向正确的IP地址来告知此信息。 Just simply having Apache recognize the name doesn't allow your other machines to know how to access it. 仅仅让Apache识别该名称就不会让您的其他计算机知道如何访问它。
Alternatively, if you run a local DNS service, you can add an entry there. 或者,如果您运行本地DNS服务,则可以在其中添加一个条目。
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. 它将告诉您的计算机将该IP用于该域。 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.
根据您的浏览器(Firefox会内部缓存)或您的操作系统(以及Windows缓存),您可能需要重新启动浏览器或刷新dns缓存。
For more information about your hosts file (including where to find it on different OSes), check this wikipedia link. 有关主机文件的更多信息(包括在不同操作系统上的位置), 请查看此Wikipedia链接。
I think it just simple, 我认为这很简单,
I always do like this. 我总是这样。 example .
例子 200.100.10.1:3000/ .
200.100.10.1:3000/。 I access my friend web application in another city.
我在另一个城市访问我的朋友Web应用程序。
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. 所以如果我没记错的话,我只输入200.100.10.1即可访问他们的应用程序。 I hope it work
我希望它能起作用
I found the answer: the solution is to make the required server the default server for my ip address. 我找到了答案:解决方案是使所需的服务器成为我的IP地址的默认服务器。 I did this by changing the top of the config file for the required site (/etc/apache2/sites-available/001-trunk in this case)
我是通过更改所需站点的配置文件顶部来完成此操作的(在本例中为/ etc / apache2 / sites-available / 001-trunk)
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. 192.168.0.234是我的网络IP地址。
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. 现在,当其他人在浏览器中输入该IP时,他们会获得我希望他们获得的站点,而不是apache默认站点。
Thanks everyone for your advice! 谢谢大家的建议!
type in the ip and port like so: 像这样输入ip和port:
127.0.0.0:80/rails 127.0.0.0:80/导轨
this will only work if permissions are set to read/write. 仅当权限设置为读/写时,这才起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.