[英]Virtual Box port forwarding misery with Ruby Sinatra:4567 / Shotgun:9292
I've got a VirtualBox CentOS 7.0
Guest OS on a Windows Ten
Host for the purposes of development, and the port forwarding simply isn't working.出于开发目的,我在
Windows Ten
主机上有一个 VirtualBox CentOS 7.0
来宾操作系统,但端口转发根本不起作用。
I have a NAT'd
network adapter (I can't use Bridged Adapters on this network) and to be fair I am much more comfortable with Bridged Adapters.我有一个
NAT'd
网络适配器(我不能在这个网络上使用桥接适配器),公平地说,我对桥接适配器更满意。 But everything else works swimmingly.但其他一切都可以顺利进行。 Except the ports 4567 and 9292 will not forward, while port 22 and port 80 work fine.
除了端口 4567 和 9292 不会转发,而端口 22 和端口 80 工作正常。
I have我有
22
, 80
, 4567
, 9292
in VirtualBox on the NAT'd adapter.22
、 80
、 4567
、 9292
添加了端口转发。CentOS 7.0
completely (and restarted) then ruled that outCentOS 7.0
完全禁用 firewalld(并重新启动)然后排除了localhost:4567
is perfect as is localhost:9292
localhost:4567
和localhost:9292
一样完美SELINUX
on guest (for good measure)SELINUX
(很好的措施)10.0.2.15:4567
/ 10.0.2.15:9292
in a vain attempt to get purchase10.0.2.15:4567
/ 10.0.2.15:9292
徒劳地尝试购买all the time I am ssh'd in on port 22
and port 80
works fine我一直在端口
22
上使用 ssh,端口80
工作正常
Is this a traffic issue or a firewall issue, is there some sort of network filtering on the VirtualBox interface that's hidden from me?这是流量问题还是防火墙问题,VirtualBox 界面上是否存在某种对我隐藏的网络过滤?
I'd love some help.我很想得到一些帮助。
NB: THE CAUSE IS SHOTGUN/RUBY NOT VirtualBox nor Firewalls nor port forwarding注意:原因是 SHOTGUN/RUBY 不是 VirtualBox、防火墙或端口转发
@Matt fixed this... his link in the comments is correct, the fix to this is one of two things: (it's actually shotgun
running ruby in development mode that causes it) @Matt 修复了这个问题……他在评论中的链接是正确的,对此的修复是两件事之一:(实际上是
shotgun
在开发模式下运行 ruby 导致了它)
CAUSE:原因:
set :bind, 'localhost'
development mode. set :bind, 'localhost'
开发模式下运行。 (link) SOLUTION:解决方案:
set :bind, '0.0.0.0'
(can also be in the config.ru) set :bind, '0.0.0.0'
(也可以在 config.ru 中) Good news is if you're looking to make localhost:4567 work this is your ticket, add the line set :bind, '0.0.0.0'
to your config and you're good to go好消息是,如果您想让 localhost:4567 工作,这是您的票,请将行
set :bind, '0.0.0.0'
到您的配置中,您就可以开始了
ANNOYINGLY IF YOU RUN SHOTGUN THIS ISN'T GOING TO BE PICKED UP令人讨厌的是,如果您运行 Shotgun,这将不会被发现
Bad news is if you're looking to make localhost:9292 work shotgun does it's own thing here:坏消息是,如果你想让 localhost:9292 工作,猎枪在这里做它自己的事情:
shotgun
won't LOOK at those ruby configs, it'll adopt it's own boot strategy, so you have to MAKE shotgun run in --host=0.0.0.0
mode: EG:shotgun
不会查看那些 ruby 配置,它会采用自己的引导策略,因此您必须使 shotgun 在--host=0.0.0.0
模式下运行:EG:# shotgun --server=thin --port=9292 --host=0.0.0.0 config.ru
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.