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

两盒软妹~` 提交于 2019-12-11 06:52:15

问题


I configured demo-spring-cas-angular to work on port 8081. When I run it on my machine (OSX) it works very well.

I have problem when it is run inside vagrant. Port 8081 is forwarded

  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

I don't have problems with other ports besides 8081 (I have access to databases, eureka registry, CAS instance).

From OSX:

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

From vagrant:

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]-->
...

I don't see any exceptions during application boot.

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

It is problem with application or with vagrant? I tried to run another application on 8081 - problem didn't occur.


回答1:


you can change the host info from application-dev.yml to be

server:
    port: 8081
    address: 0.0.0.0

so it will be available outside of the VM

127.0.0.1 is a 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 its available to all interfaces



来源:https://stackoverflow.com/questions/39074373/jhipster-spring-angular-vagrant-empty-replay-from-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!