JHipster (Spring, Angular), Vagrant - 来自服务器的空回放

JHipster (Spring, Angular), Vagrant - empty replay from server

我配置了demo-spring-cas-angular 在端口 8081 上工作。当我 运行 它在我的机器上时 (OSX) 它工作得很好。

我在 vagrant 中 运行 时遇到问题。转发端口 8081

  config.vm.network "forwarded_port", guest: 8080, host: 8080
  config.vm.network "forwarded_port", guest: 8081, host: 8081
  config.vm.network "forwarded_port", guest: 8761, host: 8761
  config.vm.network "forwarded_port", guest: 5432, host: 5432
  config.vm.network "forwarded_port", guest: 3306, host: 3306
  config.vm.network "forwarded_port", guest: 8443, host: 8443

除了 8081(我可以访问数据库、eureka 注册中心、CAS 实例),其他端口没有问题。

来自OSX:

curl http://localhost:8081/index.html#/
curl: (52) Empty reply from server

来自流浪汉:

curl http://localhost:8081/index.html#/
<!doctype html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
...

我在应用程序启动期间没有看到任何异常。

Access URLs:
----------------------------------------------------------
    Local:      http://127.0.0.1:8081
    External:   http://127.0.0.1:8081
----------------------------------------------------------

是应用程序问题还是流浪者问题?我尝试 运行 8081 上的另一个应用程序 - 问题没有发生。

您可以将主机信息从 application-dev.yml 更改为

server:
    port: 8081
    address: 0.0.0.0

因此它将在 VM 之外可用

127.0.0.1 是一个 loopback address so if you assign this IP (or localhost) to the config of your server, its not accessible from other network interfaces, so you cannot access it from outside of the VM. If you bind your server to 0.0.0.0 它对所有接口可用