Ruby on rails 如何从本地网络上的其他计算机上查看apache rails服务器?

Ruby on rails 如何从本地网络上的其他计算机上查看apache rails服务器?,ruby-on-rails,apache,Ruby On Rails,Apache,我有一个apache服务器正在运行,其中mongrels在运行rails。my rails应用程序的apache配置文件如下所示: <VirtualHost *:80> ServerName trunk.production.charanga ServerAlias max.trunk.production.charanga DocumentRoot /home/max/work/e_learning_resource/trunk/public RewriteEn

我有一个apache服务器正在运行,其中mongrels在运行rails。my 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>

ServerName trunk.production.charanga
ServerAlias max.trunk.production.charanga
DocumentRoot/home/max/work/e\u learning\u resource/trunk/public
重新启动发动机
平衡员http://127.0.0.1:5010
#将所有非静态请求重定向到精简
重写cond%{DOCUMENT\u ROOT}/%{REQUEST\u FILENAME}-F
重写规则^/(.*)$balancer://mongrel1%{REQUEST_URI}[P,QSA,L]
ProxyPass/balancer://mongrel1/
ProxyPassReverse/balancer://mongrel1/
代理主机
命令拒绝,允许
通融
#自定义日志文件位置
ErrorLog/home/max/work/e_learning_resource/trunk/log/error.log
CustomLog/home/max/work/e\u learning\u resource/trunk/log/access.log组合
我以为这会让我从另一台装有max.trunk.production.charanga的计算机上访问它,但我肯定还有一步,我想不出来。目前,如果我在另一台计算机上的firefox中的地址栏中键入我的ip地址,我会看到默认的apache服务器(带有“It works!”等),但我无法访问我的rails apache服务器。如果我在这里使用了错误的术语,请纠正我

谢谢
max

试图访问它的计算机需要知道如何将DNS条目
max.trunk.production.charanga
解析为正确的IP地址
192.168.1.42
(或服务器的IP地址)。没有人告诉它,它无法解决这个问题

您通常可以通过编辑
/etc/hosts
并将该地址指向正确的IP地址来告诉它这些信息。仅仅让Apache识别这个名称并不允许您的其他机器知道如何访问它


或者,如果您运行本地DNS服务,您可以在那里添加一个条目。

编辑您的主机文件是一个快速而简单的解决方案

添加行

192.168.1.1    trunk.production.charanga max.trunk.production.charanga
它将告诉您的计算机将该ip用于该域。根据您的浏览器(Firefox内部缓存)或操作系统(windows缓存),您可能需要重新启动浏览器或刷新dns缓存


有关主机文件的更多信息(包括在不同操作系统上的何处找到它),

我认为这很简单

我总是这样。例子。200.100.10.1:3000/ . 我在另一个城市访问我的朋友web应用程序



DocumentRoot/htdoc/trunk/我找到了答案:解决方案是使所需的服务器成为我ip地址的默认服务器。为此,我更改了所需站点的配置文件的顶部(/etc/apache2/sites available/001 trunk)

由此

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

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

ServerName trunk.charanga
ServerAlias max.trunk.charanga
DocumentRoot/home/max/work/e\u learning\u resource/trunk/public
等

NameVirtualHost 192.168.0.234:80
ServerName trunk.charanga
ServerAlias max.trunk.charanga
DocumentRoot/home/max/work/e\u learning\u resource/trunk/public
等
其中192.168.0.234是我的网络ip地址

现在,当其他人在浏览器中输入该ip时,他们将获得我希望他们获得的站点,而不是apache默认站点


谢谢大家的建议

输入ip和端口,如下所示:

127.0.0.0:80/轨道


这只有在权限设置为读/写时才有效。

Hi Kuya-就像我说的“现在,如果我在另一台计算机上的firefox中的地址栏中键入我的ip地址,我会看到默认的apache服务器(带有“It works!”等),但我无法访问我的rails apache服务器。”嗨,托弗-你说的只是将“max.trunk.charanga”解析为我机器的ip地址,不是吗?换句话说,这和他们输入我机器的ip地址是一样的。但是,当我在另一台机器上执行此操作时,我只看到默认的apache页面,而不是rails页面。我是否需要在非默认端口上运行rails apache,并将该端口添加到ip?我试过了,但似乎不起作用。@Max-不,Apache知道如何呈现页面的方式完全取决于用于访问页面的名称。您拥有的是一个命名的虚拟主机。Apache将根据访问服务器所使用的URL呈现不同的内容,因此,如果您只键入IP地址,它将呈现默认页面,因为它不知道您询问的是哪个“站点”。但是,如果您分配了一个DNS条目(或在/etc/hosts文件中添加了一个),那么当用户键入该条目时,Apache将知道您要呈现哪个站点而不是默认站点。谷歌为Apache命名的虚拟主机。
<VirtualHost *:80>
  ServerName trunk.charanga
  ServerAlias max.trunk.charanga

  DocumentRoot /home/max/work/e_learning_resource/trunk/public
  ......etc
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