DEV Community

Discussion on: Explain me Ngnix

Collapse
 
rishitkhandelwal profile image
Rishit Khandelwal

I want to know how to get my local website be visible to public. Can I just use my public IP to access it without any setups?

Collapse
 
jhilgeman profile image
Jonathan H • Edited

Not usually. There is almost always some setup and several things to consider.

  1. Your public IP usually changes unless you have paid extra to your ISP to have a static one. So you usually have to have a way to work around that (e.g. dynamic DNS).

  2. If you're on a home internet connection, your ISP might block you from doing this. A lot of ISPs don't want their customers to be serving up lots of traffic.

  3. Most people are still behind a firewall using NAT. What that means is that your public IP isn't the same as your local network IP. Basically, IPv4 (IP addresses with 4 numbers and a dot between them like 1.2.3.4) only had a couple billion IP addresses (from 0.0.0.0 to 255.255.255.255). Since there many, many more internet-connected devices than public IP addresses, a technology called NAT made it possible to create a private network with its own private IP addresses. So your public IP might be 1.2.3.4 but your computer's IP address might be 192.168.1.10. The traffic that goes to 1.2.3.4 goes to your router or firewall device, and then it has to be routed to your machine. So you usually have to configure your firewall/router to route traffic on ports 80 (the normal port for HTTP) and 443 (HTTPS) to your computer.

Then you have to consider that if your computer is down or updating or rebooting or the web server isn't running, then nobody can access your site.

You also have to consider that if you have any vulnerabilities in your website or you don't keep the web server updated or if it's not configured correctly, you could be vulnerable to hackers who might be able to access other files on your hard drive or even erase things.

So there's quite a few things to consider. It is why people who are getting started with websites usually pay for basic hosting services. Those other companies have everything already configured and they take care of almost all of those problems for you.

So while you -can- host from your local computer, it's usually a bad idea and almost always takes setup.

Thread Thread
 
rishitkhandelwal profile image
Rishit Khandelwal

Thanks!

Collapse
 
sergeypodgornyy profile image
Sergey Podgornyy

If you have a stable public IP, you can make your local website public. If you have it and your webserver is running, then you'll be available to access your website in the browser using http protocol, fe. http://18.197.136.105.

If you want to make your website available under some domain, you have to register it globally in DNS. Usually, .com is cheap and costs about $10 per year. When you'll register it, you can redirect all request for this domain to your IP.

But, as Jonathan mentioned, your home IP in most cases is unstable and it can be changed from time to time. Moreover, to have a stable website, you have to have your local machine and webserver always running, so you either need to run your private computer always up or have dedicated webserver at home. But it doesn't worse it 😉 Better host your website somewhere remote, in the cloud, fe. AWS EC2 or DigitalOcean. It costs about $5 per month for the cheapest instance.