简体   繁体   English

使用 Ruby Sinatra:4567 / Shotgun:9292 的 Virtual Box 端口转发问题

[英]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我有

  • Added port forwarding on the client for the ports 22 , 80 , 4567 , 9292 in VirtualBox on the NAT'd adapter.在客户端上为 NAT 适配器上的 VirtualBox 中的端口228045679292添加了端口转发。
  • disabled the firewalld on CentOS 7.0 completely (and restarted) then ruled that outCentOS 7.0完全禁用 firewalld(并重新启动)然后排除了
  • all ports work fine on local host ie in the vm localhost:4567 is perfect as is localhost:9292所有端口在本地主机上工作正常,即在虚拟机中localhost:4567localhost:9292一样完美
  • switched of SELINUX on guest (for good measure)在来宾上切换SELINUX (很好的措施)
  • restarted the whole VM on host systematically every time I did a network->portforward alteration每次我进行网络->端口转发更改时,系统地重新启动主机上的整个VM
  • tried 10.0.2.15:4567 / 10.0.2.15:9292 in a vain attempt to get purchase尝试10.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:原因:

  • RUBY running in default set :bind, 'localhost' development mode. RUBY 在默认set :bind, 'localhost'开发模式下运行。 (link) (关联)

SOLUTION:解决方案:

  • RUBY runs with options set :bind, '0.0.0.0' (can also be in the config.ru) RUBY 运行时选项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 工作,猎枪在这里做它自己的事情:

  • in fact 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.

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