0

I have found many similar questions, but I'm very noob with server's stuff.

I have a notebook running a linux distro (Gentoo). This distro is running Ubuntu Server using Virtualbox. In this server there is Tomcat web server listening (by default) to port 80.

Now I'd like to realize at least two use cases:

  1. Send http request to Tomcat from my Gentoo Host when there isn't an active internet connection, i.e. when I'm not in my home (probably using an http://localhost/...-like in my Gentoo's browser?)
  2. Send http request to Tomcat from any machine in the same LAN, i.e when I'm in my home (probably using an http://192.168.0.xx/...-like in my client's browser?)

Obviously in both cases the server must be able to send http response to the client.

I hope that someone can link me or write me a simple step-tutorial.

Thanks in advance.

EDIT: UPDATE, the second point works by default. The virtual server has the local 192.168.0.15 IP (probably it will change every time, but I can live with this), and if I type 192.168.0.15:8080 in any browser in my LAN, Tomcat correctly works.

So I need help only for the first point, i.e. when my notebook is disconnected from any LAN.

2 Answers 2

1

You have a notebook with Gentoo installed, and you run Virtualbox with Ubuntu Server as guest. I use a similar setup. When it's a VM, I prefer to use the desktop version for the VM. That way I can test in a browser in the VM. Maybe it uses a bit more resources, but in general you won't notice. It's a lot easier to get things done, and to get familiar with all settings. For the server part there is not much different.

What is the IP of the VM? Try "ifconfig", and see if the IP is in the same range, so 192.168.0.xx and not something like 10.0.0.xx. If it's 10.x.x.x, then you have the wrong type of network adapter chosen in the VM settings.

If it's in the same range, and you cannot connect, the firewall might be a problem. Try sudo ufw status.

Can you telnet on the VM to port 80, so are you sure Tomcat is running and listening to port 80?

Do you have openssh-server installed on the server? If you can login from the Gentoo terminal to the VM using SSH, you know the network is OK, and the firewall is probably not an issue.

Is HTTPD or Apache2 installed and running? That might cause conflicts with Tomcat running on port 80.

9
  • The IP is in the same range, within my home LAN it works without problems. Now I'm trying to access the server from Gentoo when my notebook is outside the LAN. How can I do this?
    – eang
    Mar 20, 2013 at 12:49
  • 1
    When your laptop is not on the home network, it gets a local (non-connected) ip-address like 169.254.x.x. Does this happen? What IP does your VM have then?
    – SPRBRN
    Mar 20, 2013 at 12:59
  • Nope. When I exit from my LAN, the "inet" entry disappers from ifconfig (on Gentoo host), there is only a inet6 (ipv6?) address. In the VM the ifconfig output seems the same (as if the LAN was up).
    – eang
    Mar 20, 2013 at 13:27
  • 1
    Does the VM keep that ip when you disconnect the host from the LAN and then restart the VM? If you keep a local IPv6 address, why not use that? Just try if it does something, if the guest is in the same range here too.
    – SPRBRN
    Mar 20, 2013 at 15:05
  • No, if I restart the VM, the inet entry disappears (exactly as on Gentoo). The inet6 entry on the VM says inet6: fe80::a00:27ff:feb3:89e7/64, but this address (ipv6?) doesn't work in my Gentoo's browser.
    – eang
    Mar 20, 2013 at 15:26
1

If you use a router, aad want to access it from internet or external network, then forward connection on 80 for that internal IP where the VPS is. If you want to access from same network, then do 192.168.0.100:80, or the port you have on for that (80 should be default http, so that's just example). Check any firewall that may block your connection.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .