如何在本地网络之外访问我的 sinatra 网络应用程序?
我开始我的应用程序
$ ruby app.rb -o192.168.0.105 -p4567
== Sinatra (v2.0.5) has taken the stage on 4567 for development with backup from Thin
Thin web server (v1.7.2 codename Bachmanity)
Maximum connections set to 1024
Listening on 192.168.0.105:4567, CTRL+C to stop
192.168.0.105 - - [06/Jul/2019:08:58:58 -0400] "GET / HTTP/1.1" 200 12 0.0040
我的路由器有此端口转发:
然后我尝试使用我的外部 IP - 34.62.43.89:4567(不是真实的)
但我明白
This site can’t be reached 24.61.43.68 took too long to respond.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_TIMED_OUT
我哪里错了/我遗漏了什么?
答案1
我假设您在 ubuntu 操作系统上运行 ruby/sinatra。启用 IP 转发还不够。您还应该考虑在 ubuntu 机器上设置互联网网关(https://help.ubuntu.com/community/Internet/ConnectionSharing#Ubuntu_Internet_Gateway_Method_.28iptables.29),然后尝试连接你的公共 IP。