WebServer Hosted at Home Easily

This is the procedure to self-host a WebServer on a HomeLab network. This assumes that the user has no hosted services and that this is the first attempt at hosting. The section for NginX Proxy Manager installation can be skipped if you already have a reverse proxy installation.

You need a domain name which is as little as $12 a year through Google, Cloudflare and others. In my tutorial, I use Google DNS as my domain name provider.

You need to define a CNAME record for your webserver subdomain name and an NPM record to access your webserver using that domain name and that’s what we discuss.

Create a Dynamic DNS name for your domain name at your Domain Name Provider website.

Install a dynamic dns client on your Ubuntu or Raspberry Pi server:

sudo apt install ddclient

After installation, edit the ddclient.conf file:

sudo nano /etc/ddclient.conf

Insert the following code:

# /etc/ddclient.conf
daemon=300
use=web
server=domains.google.com
ssl=yes
login=generated_username
password='generated_password' # this MUST be in quotes
Yourdomain.com

Change your credentials and domain name above as described in the video.

Test your configuration:

sudo ddclient -daemon=0 -debug -verbose -noquiet

Install docker and docker-compose:

sudo apt install curl
curl -sSL https://get.docker.com | sh
sudo usermod -aG docker your-username
newgrp docker
groups
sudo apt install docker-compose

Create a docker folder in your home folder of your server and associated folders:

mkdir docker
cd docker
mkdir npm
cd npm

Create a docker-compose file for NPM:

nano docker-compose.yml

Insert the following code:

version: '3'
services:
  nginx-proxy-manager:
    image: jlesage/nginx-proxy-manager
    ports:
      - "8181:8181"
      - "8080:8080"
      - "4443:4443"
    volumes:
      - "./config:/config:rw"

Start NPM:

docker-compose up -d

Go to your server address at port 8181 to configure NPM, In my case this is http://172.16.2.2:8181.
The initial username is admin@example.com and the initial password is change, Follow the video and update these.

Go back to the docker folder and create a wordpress folder and associated folders:

cd ..
mkdir wordpress
cd wordpress
mkdir database
mkdir html

Create a docker-compose file for WordPress

nano docker-compose.yml

Insert the following code:

version: "3.3"
    
services:
  db:
    image: mysql:5.7
    volumes:
      - ./database:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
    
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    volumes:
      - ./html:/var/www/html
    ports:
      - "80:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress
volumes:
  db_data: {}
  wordpress_data: {}

Change the passwords and port number as indicated in the video. Then start the installation:

docker-compose up -d

Visit your website at your server address and port number you specified above to continue configuration.

After configuration, visit your NPM web page and add a proxy for your www.mydomain.com to point to the address and port number of your webserver. Note that www.mydomain.com must already be defined as a CNAME record at your DNS provider pointing to your domain name.

Finally, test your new proxy by going to https://www.mydomain.com in your web browser and it should go to your website page with SSL.

Hi Scott. Just found our youtube channel today and I have to say it is great! Helps me quite a bit setting up my own LXD servers for different services and home automatition etc. on my qnap NAS.
I have just one question about this tutorial: if I understood correctly, you are saying to create a separate DNS record in the dynamic DNS service for each sub-domain. What is the advantage of this? I have just one record in my dynamic DNS service, hence all requests for all subdomains are routed to my reverse proxy which then forwards the requests to the according virtual server based on the requested subdomain.

You will want to just create a single dynamic dns record for your domain name. As an example, I have a dynamic DNS A record for scottibyte.com. I then have a CNAME record for each hosted service. For example, this forum has a CNAME record for discussion.scottibyte.com that points to scottibyte.com.
cname

Although it sounds a bit redundant, I have about 40 CNAME records that point all point to scottibyte.com. Reverse proxy is what handles knowing what services route to which internal server.

Thanks for the kudos!

Ok, CNAME is the correct name. But again, what is the advantage of CNAMEs for each sub-domain?
I don’t have them and have my reverse proxy separating the different requests based on called sub-domain. Works without any issue.

Ahh, ok. So the advantage of CNAME records is they are just aliases to your domain name record which you will want to define as a dynamic DNS A Record. I know that sounds weird because it means that all the CNAME records translate to the same address, which is true. That’s because your ISP provides your router with ONE DHCP WAN address,

So, effectively in my case https://www.scottibyte.com, https://discussion.scottibyte.com, and https://chat.scottibyte.com all end up pointing to my domain name dynamic DNS A record for scottibyte.com which means they all have the same address. Reverse proxy (NginX Proxy Manager) handles routing each of the names to the proper system inside of my private network.

If you did not have CNAME records, you would need to have a dynamic DNS A record for each and every subdomain name that pointed to a dotted IPv4 address since your ISP WAN address can change. That would mean an A record for https://www.scottibyte.com pointing to 1.2.3.4, an A record for https://discussion.scottibyte.com pointing to 1.2.3.4 and an A record for https://chat.scottibyte.com pointing to 1.2.3.4. The CNAME record requires only that it points back to the domain, so it is a shorthand.

This is a valuable information on self-host a WebServer on a HomeLab network. And also thanks for sharing all steps to proxy installation. Here you find information on dynamic IP. Thanks

1 Like