![](/img/trans.png)
[英]How can I view my rails localhost from other devices on the network?
[英]How can i see my apache rails server from other computers on my local network?
我有一個正在運行的apache服務器,在運行軌道的下面有雜亂的動物。 我的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>
我以為這可以讓我從具有max.trunk.production.charanga的另一台計算機上訪問它,但是我確信還有另外一步,我不知道。 此刻,如果我在另一台計算機上的Firefox的地址欄中鍵入我的IP地址,我會看到默認的Apache服務器(帶有“ It works!”等),但是我無法進入Rails apache服務器。 如果我在這里使用錯誤的術語,請指正我...
謝謝最大
嘗試訪問它的計算機需要知道如何將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緩存。
有關主機文件的更多信息(包括在不同操作系統上的位置), 請查看此Wikipedia鏈接。
我認為這很簡單,
我總是這樣。 例子 200.100.10.1:3000/。 我在另一個城市訪問我的朋友Web應用程序。
要么
<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>
所以如果我沒記錯的話,我只輸入200.100.10.1即可訪問他們的應用程序。 我希望它能起作用
我找到了答案:解決方案是使所需的服務器成為我的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
至
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
192.168.0.234是我的網絡IP地址。
現在,當其他人在瀏覽器中輸入該IP時,他們會獲得我希望他們獲得的站點,而不是apache默認站點。
謝謝大家的建議!
像這樣輸入ip和port:
127.0.0.0:80/導軌
僅當權限設置為讀/寫時,這才起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.