How to make my IP publicly accessible to make my local Tomcat server public?

20

11

I'm working on my desktop computer. On this machine I also run Tomcat for my Java development so that I can visit my local address:

 http://192.168.1.1:8080/myapp

Now I go to whatsmyip.com and get my IP lets say it is: 119.56.1.78

Now what I want is that: I go to another PC (not on my LAN) or any PC around the world connected to Internet and type the following address:

http:// 119.56.1.78:8080/myapp

this should show me the same page that I can access locally from http:// 192.168.1.1:8080/myapp.

Is this possible?

jayesh

Posted 2012-12-28T11:54:31.660

Reputation: 311

2Yes it's possibile, did you tried it? – Atropo – 2012-12-28T12:03:16.530

Answers

15

Yes, it is possible. It is called "Port Forwarding".

119.56.1.78 - is your public IP address.
192.168.1.1 - is your private IP address on the LAN.

To see how port forwarding is done read this very good and short tutorial with lots of nice pictures:
How to Forward Ports on Your Router

informatik01

Posted 2012-12-28T11:54:31.660

Reputation: 314

5

You need to do forward your 8080 port through your router.

If your IP changes (you have a dynamic IP or a static IP, this is determined by your ISP) you can get a host name from dyndns and set up your router to update dyndns with your new IP when it changes. this will allow you to access your application like so:

hostname.dynsns.org/your_app

Alternatively, you can rent a hosted server and a domain name.

epoch

Posted 2012-12-28T11:54:31.660

Reputation: 151

2

If it is for short term, you can use localtunnel (same like ngrok).

Just follow these steps (require: NodeJS):

  1. Install localtunnel by running

    npm install -g localtunnel
    
  2. Assumes, your app is running on http://localhost:8080/, then run

    lt --port 8080
    

    It will create a public url domain with a random name like this.

Note: You can create custom url as well (eg: lt --port 4200 -s "sangeeth", -s means subdomain).

Ta-da! It's done!

Sangeeth

Posted 2012-12-28T11:54:31.660

Reputation: 21

0

  1. Download ngrok.
  2. Run your service.
  3. Assuming your tomcat server listen on port 8080, run ngrok in command line with this command:

ngrok.exe http 8080

ngrok starts port forwarding and it looks like this:

enter image description here

Now, the client can run request with the url http://a9bb8562.ngrok.io/myapp.

KernelMode

Posted 2012-12-28T11:54:31.660

Reputation: 101

0

Please look into the following article which expains you about the static and dynamic ips you need to have static ip or a domain name to host your app so that you can access it publicly. hope the link helps you

suman

Posted 2012-12-28T11:54:31.660

Reputation: