当我不在 LAN 范围内时连接到本地 Web 服务器
我家有一个网络服务器。我已经为它分配了一个地址,例如端口 80 上的 192.168.1.123。
我知道它正在我的本地网络上运行。如果我转到网络上的另一台计算机并输入服务器的 IP 地址,我就可以看到该服务器。
有没有办法从 LAN 外部访问该服务器?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,您需要将路由器设置为将端口 80 的连接转发到您的内部 IP 地址 (192.168.1.123)。在您的路由器管理屏幕上查找
端口转发
,我想您可以通过访问http://192.168.1.1
来访问它。请记住,您的ISP可能会完全阻止端口80在这种情况下,您可以在不同的端口(例如 por 8180)上运行 Web 服务器,并让路由器将端口 8180 的连接转发到您的内部 IP。
要从外部访问您的服务器,您只需将浏览器指向您的外部 IP 地址,您可以通过访问 http: //www.ipchicken.com
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 tohttp://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
假设您已连接到互联网:
https://github.com/progrium/localtunnel
是一个快速的从互联网访问本地服务器的方法。其他语言/平台可能有类似的实现。这只是我所知道的一个。
请记住,向世界开放本地网络时需要仔细考虑安全问题。
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.
如果您使用 PHP 网络服务器,您可以这样设置:
示例:“php -S 192.168.1.123:9000 index.php”
If you use a PHP Webserver you can set it this way:
Example: „php -S 192.168.1.123:9000 index.php"