4

I have setup a centos virtual server using Vagrant and Puphpet, within the VM I have a java app running on jetty. "server is running at http://127.0.0.1:9999"

However im having trouble accessing this from my local machine, I have set up a port forward so 9999 forwards to 9999, but when i visit awesome.dev:9999 or 192.168.56.103:9999 I get a site cant be reached error.

Obviously im missing something in my puphpet config.yaml file, I'm just not sure what.

               machines:
                    vflm_b214h6dav8jj:
                        id: machine1
                        hostname: machine1.puphpet
                        network:
                            private_network: 192.168.56.103
                            forwarded_port:
                                vflmnfp_hmt0pd4imhhd:
                                    host: '5997'
                                    guest: '22'
                                vflmnfp_b74egg9hlvog:
                                    host: '9999'
                                    guest: '9999'
                        memory: '1024'
                        cpus: '1'

If I goto awesome.dev then the hello world page I put in is working, so I know the VM is up and running.

Paul M
  • 3,475
  • 8
  • 38
  • 52

1 Answers1

2

The issue is

"server is running at http://127.0.0.1:9999"

so its not accessible on any network interface other than your localhost.

You need to change this to get started the app on the IP of the server or you can use 0.0.0.0 (special IP so all interfaces can access it)

You need to change the jetty.host property, there's a few possibilities

  • start the server using the following command:

    java -Djetty.host=0.0.0.0 -jar start.jar
    
  • define the host in your connector

    <New class="org.eclipse.jetty.server.ServerConnector">
      <Set name="host">0.0.0.0</Arg>
      ....
    </New>
    
  • make a new system properties when working with ant jetty-build.xml

    <systemProperty name="jetty.ant.server.host" value="0.0.0.0"/>
    
Frederic Henri
  • 45,144
  • 6
  • 98
  • 119
  • Ok, im using Ant to start jetty and in the jetty-build.xml file I have but adding host="0.0.0.0" to this doesnt work. How would I configure it here? – Paul M Nov 07 '16 at 12:30
  • hum you can try to set as system properties ` ` – Frederic Henri Nov 07 '16 at 13:29
  • the pbm is here https://github.com/eclipse/jetty.project/blob/jetty-9.3.x/jetty-ant/src/main/java/org/eclipse/jetty/ant/ServerProxyImpl.java#L257 that host is read from the connectors definition, not sure if it can really be overriden from ant. using the system properties might work but not sure its really reliable (will depend when the properties are set vs the code) - best is really to change in your connector definition – Frederic Henri Nov 07 '16 at 13:31
  • 1
    I put the following in my jetty-build.xml and on boot it confirms its changing the value, so thats great :-) – Paul M Nov 07 '16 at 14:55