I am using ubuntu 20.04 and I fell in love with the apache2 server but the problem was that only devices connected to my wifi network were available to access the webpages and services.
Is there an easy and free way to host my apache2 server on the internet and access it from anywhere in the world??
3
Answers
Most likely you do not have a Public Ip that is available to the internet. That’s why devices connected to your WiFi can connect to it only, this is because they are on the same network. You can easily spin up a Ubuntu vm on a Cloud provider, download apache2 and assign a static Public IP to your server. There really isn’t a free way to do it, but you usually get 1 free year of subscription when you sign up for a cloud provider (Google Cloud, AWS, Azure) but there are limitations set on these free tiers.
There is a way. Assuming the following:
http://192.168.1.2/
in a browser from another machine on your wifi network.So now you have a complete setup which allows you to view the web pages from your internal network (the 192.168.1 subnet).
To see your web pages from the Internet, you will have to:
http://THE-IP-YOUR-PROVIDER-GAVE-TO-YOUR-ROUTER/
.http://10.10.10.10/
.1
Port forwarding. You tell your wifi router to accept external connections on port 80, and forward them to 192.168.1.2, port 80 (your Apache server IP)
2
Open port 80. If your router has a firewall feature, you can configure it to allow connections from port 80 external, to port 80 internal.
3
Activate DMZ. The system configured in the DMZ is no longer protected by the router. So any connection from the outside will be allowed on that server. Careful, some basic wifi routers (like mine) will allow all requests on all ports!
Final point, if you want to use a domain name instead of your IP to connect to your site. If you are paying for a static IP address from your provider, it is relatively easy to setup a DNS entry for your domain name (which you must register first) and point it to that static IP.
If you do not have a static IP, there is no guarantee that the IP will remain the same at all times. You then have to setup a dynamic DNS. There are a couple services on the web that do that. They even provide you with scripts that will publish your new public IP to them, so you do not have to update it manually all the time. Ex. DynDNS
That last part is left to you to research.
One last point, read the service agreement with your provider. Some will turn off service if you try to run a server (that is accept connections) on your dynamic IP. Some do not care. YMMV!
Just to add to create a more complete answer then allrdy given by Nic3500.
Nic3500 describes a 100% working solution since u can always change ports and make a script that mails u the current active ip address at set intervals.
so
By using Dig in unix
If u put that in a cron job and let the file get emailed to u then u will have the full free way, just check your email wherever u are in the world and it will have your current IP