12

I am running Apache/php on my localhost and would like to be able to make this publicly accessible from the internet.

I think this is achieved by port forwarding? Can someone point me in the right direction?

mavis
  • 2,630
  • 3
  • 19
  • 31
Andy Hin
  • 25,283
  • 37
  • 95
  • 135

7 Answers7

14

Well sir you should try ngrok it is free and works with everything that I throw at him (node servers, xampp etc.)

IGRACH
  • 3,036
  • 4
  • 26
  • 40
9

It depends on the connection you have.

If your machine has a public IP address, it's on the Internet already. Then all you need is to allow connections to port 80, both on the local firewall and the home/corporate firewall.

If your machine is behind a set-top-box, or inside a corporate network, chances are that you're not on the Internet. In some instances, a router does NAT (Network Address Translation) between a local (non-routable) network and the Internet. In this particular case, you need to set up port forwarding on the set-top-box or router.

ChrisJ
  • 4,883
  • 19
  • 18
  • Say my public IPv4 addr (as shown by `whatismyip` on Google) is 121.232.343.113. I have a local server running on my port 5000. I want another computer on the internet (probably someone in another city) to access the local server through an address like `121.232.343.113:5000`. Is it possible to let that happen solely through software tweaks?? – progyammer Jul 08 '19 at 12:19
  • 1
    Absolutely. If there is no firewall, no NAT, then it just works out of the box, you don't have to do anything. If your server is behind a proxy, you need to allow connections to port 5000. If your server is behind a NAT, you need to instruct the NAT to redirect port 5000 of its public IP address to port 5000 of your machine in the LAN. That's very easy to do with most NAT boxes. – ChrisJ Nov 04 '19 at 21:13
4

You might want to check out Pagekite - it's an open-source software that allows you to expose your local resources to the outer internet without you needing to reconfigure your router or firewall.

There's a similar service called Show off which does much the same thing, although it seems a bit more limited.

Már Örlygsson
  • 13,548
  • 3
  • 38
  • 51
1

You could try beame-insta-ssl, it's a good way to get free tunneling services and a free SSL certificate to expose your localhost. It's open source on git here: https://github.com/beameio/beame-insta-ssl/

Hilli
  • 19
  • 1
0

Another tool for port forwarding through OpenVPN or SSH tunnel is https://portmap.io . If you're running multiple vhosts on local Apache, you can set host-header with required hostname.

bitree
  • 26
  • 1
0

Only port forwarding would work but you would need to connect to your server thru it's IP.

take a look at dyndns.com, there you can get a DNS ID that points to your server.

After that you set your router port 80 (HTTP) or 443(HTTPS) to point to your PC HTTP server port ( this can be any port you wish)

Cristiano Fontes
  • 4,620
  • 6
  • 38
  • 71
0

It depends of what do you mean localhost? Each system has its own "localhost".

If you mean that you have something like: "your system"<-->"gateway/wifi router"<-->Internet than you should configure port mapping from your router external interface to your server' IP address. Check your gateway/router documentation for more information.

Elalfer
  • 5,146
  • 18
  • 24