简体   繁体   中英

Apache: how can I access my webpage from a computer outside my network?

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.

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)?

Thank you!

Short answer:

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.

Long answer:

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.

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.

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. Eg 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).

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.

What you need is to identify your home computer from the whole internet in order to access from outside.

This tutorial can help you http://kyokasuigetsu25.wordpress.com/2011/01/21/how-to-access-localhost-of-computers-outside-the-network/

But if you only have plain html files ( css, js too ) you could use Dropbox and share your sites folder. This way you could be working locally and files would be synced to your public folder

Hope it helps

Most gateways (router) have an VirtualServer option which you can point to the local server (192.168.0.50)

You could use something like dyndns.org to setup a permanent hostname to your server. ie mylocalserver.dyndns.org

A public name for your machine needs to be set up in DNS to point to your networks' router. Then you will need to set up your router to redirect traffic for that name to the machine in question. Also the firewall needs to be set up to allow that.

If you have sufficient privilege to configure the router (on the gateway machine), then you can use "port forwarding" to do that.

Go to your router settings and configure it so that it forwards the packets it receives on port 80 to your machine. Assuming your router has a valid IP itself (say xxxx) you can access your Apache server on: http://xxxx/ .

You can use any other port instead of 80 and access your Apache through http://xxxx:PORT/ of course.

If you don't have sufficient privileges, then nothing comes to my mind except using reverse tunneling using SSH or similar protocols.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM