How to access the Tomcat that is inside a Vagrant machine?

Asked

Viewed 185 times

0

I’m starting to learn about Vagrant. I started provisioning a machine with Centos 7 Minimal, I installed Java and Tomcat, I ran Tomcat, I checked the processes it is running, but I can’t access it through my machine.

I set a static ip for this machine in several ways, but the last configuration was as follows::


Vagrant.configure(2) do |config|

  config.vm.define :tomcat do |tom|
      tom.vm.box = "relativkreativ/centos-7-minimal"
      tom.vm.network "private_network", ip: "192.168.33.10"
  end

end

I ping from my machine on the ip I set up (192.168.33.10) and it’s all right, even when I turn off my vm from Vagrant the ping to work as it should be.

Apparently all right but I can’t access the URL through my machine: http://192.168.33.10:8080 stating that the page is not available. However, when I check on vm the port 8080 is being used by java as well as it should be.

If it serves as extra information:

  • My machine is a Mac
  • Yes, all the settings in the Vagrant that I made
  • Both java and Tomcat installed via yum

Does anyone know what it could be? How do I access Tomcat from my machine? :)

1 answer

0


I found several solution suggestions that were based on tinkering with Tomcat’s settings, but eventually I found the correct solution that was the Centos firewall.

The solution is to activate port 8080 in the firewall with the following commands:


    firewall-cmd --zone=public --add-port=8080/tcp --permanent 
    firewall-cmd --reload

This solution was found in serverfault: https://serverfault.com/questions/677743/not-able-to-access-tomcat-webserver-from-another-machine-in-the-lan?newreg=016ef66355174df3aa4ccf537d5cc536

Browser other questions tagged

You are not signed in. Login or sign up in order to post.