How to install a mini web server on a router
In this page I describe how to install a DLNA server on a router (Asus RT-AC56U)
- we use an Entware installation, so please
refer to this page on how to install Entware on a router.
All the above mentioned destination folders already exists in Entware
installation, except "/opt/share/www/minihttp", we have to create it and then
copy the file "index.html". Inside folder "/opt/share/www/minihttp" we have to
create also a subfolder called "cgi-bin", as this mini web server supports also
# mini_httpd - small HTTP server config # a hostname to bind to, for multihoming (set this at bind 0.0.0.0 problem) #host=setthis # a directory to chdir() to at startup dir=/opt/share/www/minihttp # a directory to chdir() to after chrooting #data_dir=/opt/share/www port=8084 user=nobody nochroot charset=iso-8859-2 cgipat=**.php|**.cgi|**.sh logfile=/opt/var/log/mini_httpd.log pidfile=/opt/var/run/mini_httpd.pid # P3P server privacy header http://www.w3.org/P3P/ #p3p= #vhost
This is a brief description of the most important variables included in above-mentioned configuration file:
Another step is to change the owner of all folder "/opt/share/www/minihttp"
using the same "user" value inside configuration file, in this case "nobody",
using the command line "chown -R nobody:nobody /opt/share/www/minihttp".
Whenever we add a file inside the web server root folder "/opt/share/www/minihttp",
we have also to change the owner of the added file.
How to setup an USERID and a password on web server
Normally when we start this mini web server, we can browse inside this web
server without authentication. But we would like to a have an authentication
procedure in order to grant this web server only to few users and not to all
mini_httpd-htpasswd -c testpwd admin Adding password for admin. New password: Re-type new password: cat testpwd admin:Yqm96b92BYBMw
The above-mentioned "testpwd" file contains a line "user:password" including
an username and the encrypted password; obviously you can use more than one user
inside the output file, you should remember to discard the "-c" parameter in
command "mini_httpd-htpasswd" if the output file already exists.
mini_httpd-htpasswd testpwd administrator Adding user administrator New password: Re-type new password: cat testpwd admin:Yqm96b92BYBMw administrator:jloexXcjKyLcI
The above-mentioned "testpwd" file must be renamed to ".htpasswd" and must be copied to the root folder of the web server (default folder is "/opt/share/www/minihttp"). In this way whenever we open the browser and we go to the web server's internet address, the browser will ask for username-password authentication.