简体   繁体   English

我如何从本地网络上的其他计算机上查看我的Apache Rails服务器?

[英]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.

相关问题 如何从网络上的其他设备查看我的rails localhost? - How can I view my rails localhost from other devices on the network? 我可以将数据库保留在本地网络上,但可以在托管服务上部署Rails应用程序吗? - Can I keep my database on my local network but deploy my rails app on a hosting service? 为什么在heroku服务器上看不到Rails的任何日志输出? - Why can't I see any logging output from Rails on my heroku server? 为什么在端口80上可以看到我的Apache服务器,而在端口3000上却看不到我的Webrick服务器? - Why can I see my Apache server on port 80, but not my Webrick server on port 3000? 如何确保来自我的Rails服务器的请求是从我的Rails视图发送的? - How can I ensure that the request coming to my Rails server was sent from my Rails view? 如何防止除iPhone应用程序之外的其他任何东西与Rails Web应用程序通信? - How can I prevent anything other than my iPhone app from communicating with my Rails webapp? 如何修复Ruby / Rails本地环境 - How can I fix my Ruby/Rails local environment 如何使用Rails将图片从Amazon s3存储桶获取到本地系统? - How can I take image from the amazon s3 bucket to my local system using rails? 我如何在iPhone上通过Rails在Mac上运行Rails应用程序 - How can I see on my iPhone the rails app is running on my mac via Passenger Rails试图解决开发机器上的延迟问题-在哪里可以看到Web服务器请求日志? - rails trying to trouble shoot latency on my development machine - where can I see the web server request log?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM