从外部 LAN 访问虚拟主机
我正在建立一个 Web 开发平台,使在本地计算机上编写和测试所有代码变得尽可能容易,并将其与我的 Web 服务器同步。我设置了多个虚拟主机,以便可以通过输入“project”而不是“localhost/project”作为 URL 来访问我的项目。
我还想进行设置,以便我可以从任何网络访问我的项目。我注册了一个指向我计算机 IP 地址的 DYNDNS URL。
在我设置虚拟主机之前,这在任何地方都非常有效。现在,当我尝试通过输入 DYNDNS URL 来访问我的项目时,我收到 403 禁止错误消息:“您无权访问此服务器上的 /”。
为了设置我的虚拟主机,我编辑了两个文件 - system32/drivers/etc 文件夹中的hosts 和 WAMP 安装的 Apache 文件夹中的 httpd-vhosts.conf。
在主机文件中,我只是添加了与 127.0.0.1 关联的服务器名称。我将以下内容添加到 http-vhosts.conf 文件中:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "c:/wamp/www/ladybug"
ServerName ladybug
ErrorLog "logs/your_own-error.log"
CustomLog "logs/your_own-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "c:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
知道为什么我无法通过键入 DYNDNS URL 来访问我的项目吗?另外,是否可以设置虚拟主机,以便当我从网络外部的随机计算机输入 http://projects 时,我访问 url.dyndns.info/projects(又名我家用计算机上的 WAMP 项目)?
非常感谢帮助,谢谢!
I'm setting up a web development platform that makes things as easy as possible to write and test all code on my local machine, and sync this with my web server. I setup several virtual hosts so that I can access my projects by typing in "project" instead of "localhost/project" as the URL.
I also want to set this up so that I can access my projects from any network. I signed up for a DYNDNS URL that points to my computer's IP address.
This worked great from anywhere before I setup the virtual hosts. Now when I try to access my projects by typing in my DYNDNS URL, I get the 403 Forbidden Error message, "You don't have permission to access / on this server."
To setup my virtual hosts, I edited two files - hosts in the system32/drivers/etc folder, and httpd-vhosts.conf in the Apache folder of my WAMP installation.
In the hosts file, I simply added the server name to associate with 127.0.0.1. I added the following to the http-vhosts.conf file:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "c:/wamp/www/ladybug"
ServerName ladybug
ErrorLog "logs/your_own-error.log"
CustomLog "logs/your_own-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "c:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
Any idea why I can't access my projects from typing in my DYNDNS URL? Also, is it possible to setup virtual hosts so that when I type in http://projects from a random computer outside of my network, I access url.dyndns.info/projects (a.k.a. my WAMP projects on my home computer)?
Help is much appreciated, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我偶然发现了 apache 配置,但听起来当请求来自本地网络外部时,您的身份验证就搞砸了——您使用的是 mod_auth 吗?
尝试通过将其添加到您的
或
条目来启用从所有网络的访问:I stumble through apache configs but it sounds like your authentication is screwed up for when the requests are coming from outside your local network--are you using mod_auth?
Try enabling access from all networks by adding this to your
<VirtualHost/>
or<Directory/>
entry:我知道这是一个老问题,但我最近花时间研究这个问题并发布我的发现。
这与路由器查找地址和内部处理请求的方式有关。我在这里用图表发布了更多信息: http:// /twigstechtips.blogspot.com/2012/01/accessing-dyndns-address-within-lan.html
I know this is an old question but I've recently took the time to look into this issue and post my findings.
It's to do with the way your router looks up the address and deals with the request internally. I've posted more information here with diagrams: http://twigstechtips.blogspot.com/2012/01/accessing-dyndns-address-within-lan.html