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.