nginx
The 2025 version of setting up on a home network to serve a static local website is as follows. (Note: the file /etc/nginx/nginx.conf
does not need editing at all, since it loads *.conf
files under the conf.d
folder.)
-
Install nginx
sudo apt update sudo apt install nginx-light
-
Upload a folder to be served, e.g.,
ck.lo
in the example above to be under/var/www/
. -
Create a file named
virtual.conf
under/etc/nginx/conf.d
, and populate it with the following:server { listen 80; server_name ck.lo; location / { root /var/www/ck.lo; index index.html; try_files $uri $uri/ $uri.html =404; } error_page 404 /404.html; }
Add more server blocks to the file, if there is a need to serve more than one local website. Test it with
sudo nginx -t
to ensure there are no errors. -
Set permissions for the server folder
/var/www
sudo adduser $USER www-data sudo chown -R www-data:www-data /var/www sudo find /var/www -type d -exec chmod 755 {} \; sudo find /var/www -type f -exec chmod 644 {} \;
-
Reload nginx
sudo systemctl reload nginx
-
Optional: In
/etc/pihole/custom.list
, set local DNS like so. The local IP address in the following is but an example.10.0.1.100 ck.lo
With this, the local website should be accessible at http://ck.lo