Allowing access to localhost outside network

7

3

I have a Netbeans project running on localhost with Tomcat and MySQL, all is well.

I now want to show my progress to someone in another part of the country.

How do I let him access my website outside of my network?

Meke

Posted 2011-01-04T14:04:32.917

Reputation: 173

Do you have a router in front of you? You could forward a specific portion of traffic down to your localhost:8080... – Aaron McIver – 2011-01-04T14:52:02.230

I do have access to the router, yes. Tried forwarding the 8084 port with no luck – Meke – 2011-01-04T14:59:02.550

Answers

7

You need to check the following, in roughly this order:

Local Computer:

  • Firewall: Allow incoming connections on the required port.

  • Server: I've not used Tomcat, but you should ensure it is configured to allow connections from other IP addresses, it may be configured to only work locally.

At this point, it is worth testing that you've got this right by connecting to the LAN IP of this computer from another machine on the same LAN. Otherwise you risk spending a lot of effort messing around in the later steps to find this is blocking the entire process

Local Router:

  • Port Forwarding: Forward all inbound connections to the required port on to the IP of the local computer with the same port*. This is easier if the local computer has a fixed IP, but will work if it is DHCP but requires a little more caution (you just might have to check the configuration each time).
    **This isn't strictly necessary, you could have external port 80 forwarded to the relevant port, allowing the third party to use just the IP address, and not have to use the port in the URL.*

Internet Connection

  • Port Blocking: Some ISPs block inbound ports to prevent home users from using a (cheaper) home connection for business purposes. You could try a non-standard port number to see if this helps.

Third Party:

  • Connection: You need to give them your WAN IP address, your router should be able to tell you what this is. Otherwise, try something like http://whatismyip.com/ to find out what you IP is.
    They then need to visit http://<IPAddress>:<port>/

DMA57361

Posted 2011-01-04T14:04:32.917

Reputation: 17 581

Well, let's try this then. Starting from top. Access from other device. Check. Portforwarding... I'll check, seems there's going to be a fight with the router... – Meke – 2011-01-04T15:20:51.777

1While I'm confident this answer is correct, I found out my parents(visiting) have an ingenius setup of 2 routers, serial connected... Marking as answered, beginning to swear. – Meke – 2011-01-04T16:04:02.253

@Meke, I'm not sure how you mean serial connected...? But can you setup one router to port forward to the other which port forwards to your local machine (assuming each router forms its own network, and the second isn't just working as a switch)? – DMA57361 – 2011-01-04T16:08:27.957

Well it's WALL -cable> ADSL router -cable> wireless router -wifi> computer... The ADSL Router forms 192.168.0.1, wireless 192.168.1.1, the ADSL router is set to bridging – Meke – 2011-01-04T16:09:57.347

@Meke Wireless router or access point? And if the ADSL router is connected to the internet and bridging then it's not handling your internet connection (or, what is it bridging?)? Is anything else connected to the ADSL router or just the wireless? – DMA57361 – 2011-01-04T16:13:30.903

No, the only non-wireless device is connected to the wireless router. I'm not sure about the distinction between router and WAP. But as said, the ADSL router is only connected to the wall and the wireless router – Meke – 2011-01-04T16:20:40.703

Further investigation show the wireless routers WAP feature is ON – Meke – 2011-01-04T16:22:05.367

@Meke Are you able to connect your hosting computer directly (by cable) to the ADSL router, and bypass as much of the setup as possible? – DMA57361 – 2011-01-04T16:22:12.243

@DMA57361 Sadly not an option, no. – Meke – 2011-01-04T16:23:30.807

@Meke what's the local IP and subnet of your computer when connected to the Wireless? I've just spotted that the ADSL and Wireless are probably on different subnets (see 192.168.**0**.1 vs 192.168.**1**.1) and the ADSL cannot communicate with you (to port forward) if you're on a different subnet. If this is the case I've a feeling you're going to have to try getting the router to port forward to the wireless and that port forward to the computer. – DMA57361 – 2011-01-04T16:26:33.970

My computer is 192.168.1.5. The wireless being 1.1, adsl being 0.1, I can however reach the adsl router via a wireless computer (192.168.0.1) – Meke – 2011-01-04T16:27:55.373

@Meke (All the following assumes your subnet mask is 255.255.255.0, so check that as well). That is because your computer is probably configured to use 1.1 as it's gateway. It can't see 0.1 on it's subnet, so asks the gateway, which can see 0.1 and it can makes the connection for you. The ADSL router, however, is going to be using your ISP as it's gateway so it won't be able to see back through the wireless, because it never asks the wireless to look. I've got to disappear for a bit. Good luck, post any updates and I'll see if I've any further suggestions when I'm back at a computer. – DMA57361 – 2011-01-04T16:30:54.360

That's the correct subnet, yes. And I assume your observation is correct as for example a Win7 machine only maps the 1.1 router and then the net. (But shouldn't the adsl being in bridging just forward everything) – Meke – 2011-01-04T16:34:04.460

@Meke - I don't think the ADSL router can bridge in this scenario (because it'd be trying to placing all LAN machines on to the WAN network - which it can't - so it has to create it's own local network for the local devices). What you probably want is for the wireless router to be bridging instead, you want the wireless router to bridge the ADSL network out to it's wirelessly connected clients, thus not creating a second network and meaning the router can then see (and forward to!) all the machines connected to the wireless. See if it has an "wireless access point" mode you can put it in to. – DMA57361 – 2011-01-04T19:19:44.860

So what you means is WALL -cable> ADSL -cable> Wireless set to 'bridging' -everything else> ? – Meke – 2011-01-06T14:36:18.863

@Meke, I think so. If the wireless doesn't create it's own network then the ADSL should be able to see everything to forward packets to. – DMA57361 – 2011-01-06T14:42:56.603

1

I'll assume that the website isnt live, because otherwise, well we wont get into that. Easiest way to show him your project is to have netbeans compile the latest working model, find the folder all the info is stored in, zip that puppy up, upload it to any one of a plethora of file hosting sites, and give him the link, if you want him to be able to fully test the site. when he gets the file, have him open up Websitename.htm(l) and he can literally browse it like its live.

if you just want him to be able to look at what you're doing, take a few screenshots and email them to him.

Jasen

Posted 2011-01-04T14:04:32.917

Reputation: 391

I'd like him to just connect to my ip and look at it in the same way I do via localhost:8084 ? – Meke – 2011-01-04T14:34:12.240

okay, well i dont know much about servers and macs, so my solution will require you to be there when he does that. look up a program called teamviewer, have both him and you install it, it is i believe available for every os,trade info and he can actually view whats on your screen. – Jasen – 2011-01-04T14:36:47.767

Appreciate the attempt to help, but the only option here is to let him access via browser. – Meke – 2011-01-04T14:38:03.560

okay well ill flag this up so someone who knows more will look at it. – Jasen – 2011-01-04T14:39:50.870

1

You need to do a number of things:

  1. Ensure that you can reach the site from another computer on the LAN
  2. Configure the computer running Tomcat to have a fixed IP address on your LAN
  3. Forward the required port(s) from your router to the fixed IP of the Tomcat server
  4. Optionally use DynDNS's Dynamic DNS service to allow this person to find you when your WAN IP changes

If you go down the DynDNS route they have their own SE site where we can give you lots of help in getting things working.


To avoid re-writing the entire thing, I'll direct you to this guide on the DynDNS community site.

The first part should be simple enough. Can you connect to the LAN IP of the Tomcat server, using a web browser?

Cry Havok

Posted 2011-01-04T14:04:32.917

Reputation: 3 486

If you could clarify these steps a bit, im sure it wouldn't be regretted. Because honestly i wouldnt know where to start. But once thats done, im sure this is the answer. – Jasen – 2011-01-04T19:27:44.967

0

Ngrok is designed specifically to do this with very little hassle.

https://ngrok.com/

Example:

ngrok http 8080

Creates a random, publicly accessible URL, that forwards requests to your localhost on port 8080.

Not sure if I need to state it, but I have no affiliation. Just love the software.

comfytoday

Posted 2011-01-04T14:04:32.917

Reputation: 101