Uther Pendragon
Posts: 1
Joined: Mon Oct 21, 2019 1:16 am

Hosting a Web Server on the Internet.

Mon Oct 21, 2019 1:36 am

Greetings

I have a Raspberry pi running a Apache Web Server however it only accessible on the local WIFI network.

I have searched the length and breadth of the land and yet found nothing that is definite. Cryptic forum posts about port forwarding, port triggers, Website hosting companies, you need a domain name (which I now have) subscribe to this, blah, blah, blah.

Any help would be appreciated :)

-Uther Pendragon of Camelot
May be long gaps between replies and posts.

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Hosting a Web Server on the Internet.

Mon Oct 21, 2019 9:19 am

Your router has a public IP address (that's how it can talk to Google and RaspberryPi.org). I'm going to assume your Raspberry Pi has a fixed IP address of 192.168.3.14 (to make my examples easier).

Your LAN uses a private network which is usually 192.168.0.0 to 192.168.0.255 or 192.168.1.0 to 192.168.1.255 with your router at http://192.168.0.1 or http://192.168.0.254 o http://192.168.1.1 or http://192.168.1.254.

To bridge the gap between your private network and the big wild and ugly public internets you need a process called port forwarding active on your router.

That says if a random punter from out in the internets connects to http://198.51.100.1:80/ [dummy address] or connects to http://www.example.co.uk:80/ your router will "port forward" that request to your Raspberry at http://192.168.3.14:80/ and your web server will send back an index page.

The first step is to look at your router's configuration pages. You can find the address for that from your Raspberry with an ip route | grep default command.

Next step is to search google for "<myrouterbrand> port forwarding" with the right brand and model in that search. For example: https://www.google.com/search?q=BT+Hub6+port+forwarding

You also need to discover your public IP address. Which you can get from http://ip4.me/ that will be needed for your purchased domain.

In some parts of the internets your ISP will have your public IP address behind a carrier-grade NAT. If that is the case then you can't run a public web server from your network. That is almost guaranteed if your internet connection is through mobile phone tethering or through an "internet on legs" dongle.

Before doing ANY of this stuff make sure you've done some of the security basics at: https://www.raspberrypi.org/documentati ... ecurity.md
because if you don't do that it's about four minutes before your Raspberry Pi WILL BE compromised by a hacking attempt.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Unleavened
Posts: 5
Joined: Mon Oct 14, 2019 7:28 am

Re: Hosting a Web Server on the Internet.

Tue Oct 22, 2019 4:29 pm

I recommend you to use CloudFlare. It's basically a reverse proxy, meaning that when someone visits your website, they connect to CloudFlare, which connects to you, so the visitor won't see your IP, but CloudFlare's. This will prevent from people DDOSing your home network. Also make sure to configure iptables firewall, so that it only accepts connections on port 80 and 443 from CloudFlare's IPs and local IP addresses.

Return to “Networking and servers”