Local Hosting pt. III: Port Forwarding

Ok, so now we got the website running on your local server and even better, its running a flask server. Now if you want to show it all you have to do is invite them over and then give the IP address, oh and yes they have to be on the wifi...there's got to be a better way!

Obviously there is. We now need to do some port forwarding. Which of course means even more time in configuration files.

Step 1: Opening the Port

Before you do anything else, you need to go into your router's admin page and then open a port. I have a netgear genie and will be walking through how to do port forwarding on that system.

  1. Click on the Advanced Tab
  2. Click on Advanced Set Up
  3. Click on Port Forwarding
  4. Change the Service Type to HTTP and enter the IP Address of the server that you are using
  5. Next check and see if port 80, which handles HTTP requests, is open on this site

If your port is open and you put in the correct server. Apache should now be serving your webpage to the your external IP address!

Step 2: Using Google Domains as your DNS

But you don't want to give people your external IP address in order for them to go to your website right? You just want to give them a domain name and they can get there from that, you know like how every website works?

You can buy a domain (really rent) from many different providers, but I choose google because I figured that they had the whole website shebang down at this point. All you have to do at this point is enter your external IP address as your existing website and google will forward traffic there whenever someone enters your web address.

Step 3: Making Sure People See the Right Thing

At this point, it is most likely that people will see the apache test page when they go to your website, or even worse some sort of error page.

This is because your apache web server is still serving whatever file you have inside of /var/www/html at this point. To remedy this (if this in fact something you want to remedy), you need to disable that default page and restart your server.

sudo a2dissite 000-default.conf
sudo service apache2 restart

As long as you followed the steps in Local Hosting pt. II, your domain should now point to your flask app!