Apache:如何从网络外的计算机访问我的网页? [英] Apache: how can I access my webpage from a computer outside my network?

查看:45
本文介绍了Apache:如何从网络外的计算机访问我的网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从网络外的计算机访问我的网页.我们的网络有像 192.168.0.1-192.168.0.255 这样的 IP.网络通过本地网关 192.168.0.1 连接到 Internet,并到达 DNS 服务器 193.xxx.xxx.xxx.

I want to access my webpage from a computer outside the network. Our network has IPs like 192.168.0.1-192.168.0.255. The network is connected to Internet through a local gateway 192.168.0.1 and gets to DNS server 193.xxx.xxx.xxx.

假设我的计算机的 IP 为 192.168.0.50.如何从我的服务器 (Apache) 访问我的网站,而不是来自我们网络的计算机(比如 254.231.52.xxx)?

Let's say my computer has the IP 192.168.0.50. How can I my website from my server (Apache) from a computer which is not from our network (let's say 254.231.52.xxx)?

谢谢!

推荐答案

简答:

解决方案是找出路由器的外部 IP",并启用端口 80 和 443 到本地 IP 的端口转发.

The solution to this would be to find out the 'external IP' of your router and enable a port forwarding for port 80 and 443 to your local IP.

长答案:

互联网分为公共"和私有"IP 空间.私有 IP 通常不能从公共"IP 直接访问.来自 192.168.0.1-255 的 IP 来自这些私有子网之一.

The Internet is divided into 'public' and 'private' IP spaces. Private IPs are usually not directly accessible from a 'public' IP. The IPs from the 192.168.0.1-255 are from one of these private subnets.

您的路由器(在家里)通常有多个 IP.一个或多个来自您的本地专用网络 (192.168.0.X) 和一个来自您的本地 ISP(我猜是 193.xxx.xxx.xxx,因为您的 DNS 在该网络中)来自公共"空间.

Your router (at home) usually has multiple IPs. One or more from your local private network (192.168.0.X) and one from your local ISP (I guess something like 193.xxx.xxx.xxx because your DNS is in that network) which is from the 'public' space.

要使用来自公共 IP 的私有 IP(例如提到的 254.231.52.xxx)连接到您的计算机,您必须连接到路由器的公共 IP(193...一个).您还必须启用一种称为端口转发"的机制.这有效地将所有互联网流量到达转发端口上的路由器的公共 IP,并将其传输到您配置转发的私有 IP.例如.254.231.52.. -> 193...:80 -> 192.168...:80通常家用路由器有一个配置页面,您可以在其中执行此操作.您可能需要使用的端口是 80 (http) 和 443 (https).

To connect to your computer with the private IP from a public IP like the mentioned 254.231.52.xxx you would have to connect to the public IP of your router (the 193... one). You would also have to enable a mechanism that is called 'port forwarding'. This effectivley takes all internet traffic arriving at the public IP of your router on the forwarded ports and transfers it to the private IP you configured the forwarding to. E.g. 254.231.52.. -> 193...:80 -> 192.168...:80 Usually home routers have a configuration page where you can do this. The required ports you would probably use are 80 (http) and 443 (https).

另一种可能性是使用所谓的 http 代理,通常也支持作为家庭路由器的配置选项.你应该参考你的路由器手册来了解这方面的配置说明.

Another possibility is using so called http-proxies which are also usually supported as a configuration option one home routers. You should refer to the manual of your router for configuration instructions of this.

这篇关于Apache:如何从网络外的计算机访问我的网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆