Connecting to Local Web Server when I am Outside my LAN

自古美人都是妖i 提交于 2019-12-29 03:28:07

问题


I have a web server running out of my home. I have assigned it an address such as 192.168.1.123 on port 80.

I understand that this is running on my local network. If I go to another computer on my network and type in the server's ip address, I can see the server.

Is there a way to access this server from outside my LAN?


回答1:


Yes, you need to set your router to forward connections to port 80 to your internal IP address (192.168.1.123). Look for Port Forwarding on your router admin screen which I would imagine you access by going to http://192.168.1.1

Keep in mind that your ISP may block port 80 completely in which case you can run your web server on a different port (for example por 8180) and have your router forward connections to port 8180 to your internal IP.

To access your server from outside, you just need to point your browser to your external IP address which you can find out by going to http://www.ipchicken.com




回答2:


Assuming you have a connection to the internet:

https://github.com/progrium/localtunnel

is a quick way to access your local server from the internet. There might be similar implementations in other languages/platforms. This is just the one I know about.

Remember that security issues need to be carefully considered when opening your local network to the world.




回答3:


If you use a PHP Webserver you can set it this way:

php -S <YourIPAdresse>:<SomePortNumber> <StartPHPpage>

Example: „php -S 192.168.1.123:9000 index.php"



来源:https://stackoverflow.com/questions/7404699/connecting-to-local-web-server-when-i-am-outside-my-lan

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!