Home > Enterprise >  How to host a website locally but with .com domain and accessible on internet
How to host a website locally but with .com domain and accessible on internet

Time:09-17

I've bought a .com domain from a provider on the internet. But, I want to host it locally.

I know that I can host a local web by using XAMPP or WAMP, but I want to make it accessible on the internet.

I also know that we could host a web to be accessible on the internet like ngrok, serveo, etc.

But, I want it with my .com domain that I bought. Could this possible? How to? Is there any references?

Thanks in advance ^_^

CodePudding user response:

It seems to me you are asking 1. if it is possible to map a DNS entry such that traffic to the URL would be directed to a server in your personal network, and 2. if it is possible, how to do it.

The answer to the first question is yes, it is possible. The second question is difficult to answer because it depends on many factors such as your ISP, country, your web host provider's rules and services, etc.

First, you must determine two IP addresses:

  • The public IP address for your network (whatismyip.com)
  • The private IP address of the local machine which will host your website (typically (192.168.0.x)

Then, you must enable port forwarding in your router configuration, such that any requests to port 80 and/or port 443 on the external interface (public) will be forwarded to the internal port on which your website is hosted. If done properly, putting the public IP in your browser will take you to the website you are hosting locally.

Once you verify access via public IP, then you must go into your DNS entries on your domain host and create a CNAME record which points your root domain (www.yourwebsite.com) to your public IP address. That will route all traffic to your .com to your local server.

I do NOT recommend doing this however, and would caution against it, because it leaves your local server/network open to the public, and makes your domain vulnerable to things such as spoofing etc. To do it properly, you should obtain a security certificate for your domain through a Certificate Authority (CA) - generally, you can request a certificate via your domain hosting service. Once you have a certificate, you must upload the key to your server and configure your web application/hosting service to use the certificate, and then change your port forwarding to use 443 instead.

This is a very complex topic that takes time to learn, and your question is extremely non-specific. There is no good place to start really, and no shortage of information/resources available online. To start, you need to understand how your DNS works. For any local webhosting, port forwarding is important to learn. You should also determine if your ISP blocks the forwarding of certain external ports, which effectively disables any private webhosting.

  • Related