Code: Select all
httpd -v -f -h /var/www/html -c /usr/share/pkg/testing/webserver/httpd/httpd.conf
https://oldwiki.archive.openwrt.org/doc ... http.httpd
The "-v" is the verbose option and the "-f" means run the server in the forground. These two options are useful for troubleshooting. I learned this from [2]:
https://blog.madadipouya.com/2018/06/03 ... g-busybox/
Now for troubleshooting it might be helpful to type in a url in the web-server and see the contents of the directory. Unlike apache and openbsd-httpd, you cannot do this by specifing the option, "directory auto index". Instead, you have to do this -- as noted in the source -- with a cgi, script called cgi-bin/index.cgi.
There is an example "c-based" cgi script in the source to do this but in my opnion "c code" is much more complicated than a simple bash scripts. I wrote the following bash script to list the contents of the directory and all the enviornmental varialbes:
Code: Select all
#!/bin/sh
echo "Content-type: text/html" # Tells the browser what kind of content to expect
echo "" # An empty line. Mandatory, if it is missed the page content will not load
echo '<html>
<header><title>This is title</title></header>
<body><pre>'
ls -a "${PWD}/..${REQUEST_URI}"
echo ""
printenv
echo '</pre></body>
</html>'
Note that you can put html in any sub directory of the server home director and the httpd web server will render it. To start I recommend googling how to do a simple "HTML hello world".
P.S. here is some exampales of the exported cgi variables
Code: Select all
CONTENT_TYPE=application/x-www-form-urlencoded
GATEWAY_INTERFACE=CGI/1.1
REMOTE_ADDR=192.168.1.180
QUERY_STRING=Zbr=1234567&SrceMB=&ime=jhkjhlkh+klhlkjhlk+%A9%D0%C6%AE%C6%AE&prezime=&sektor=OP
REMOTE_PORT=2292
CONTENT_LENGTH=128
REQUEST_URI=/cgi-bin/test
SERVER_SOFTWARE=busybox httpd/1.35 6-Oct-2004
PATH=/bin:/sbin:/usr/bin:/usr/sbin
HTTP_REFERER=http://192.168.1.1/index1.html
SERVER_PROTOCOL=HTTP/1.0
PATH_INFO=
REQUEST_METHOD=POST
PWD=/www/cgi-bin
SERVER_PORT=80
SCRIPT_NAME=/cgi-bin/test
REMOTE_USER=[http basic auth username]
but if you use the printenv command that I use in my example cgi script you can get real values rather than examples from the documentation.
Notes
------------
1 - https://oldwiki.archive.openwrt.org/doc ... http.httpd
2 - https://blog.madadipouya.com/2018/06/03 ... g-busybox/
3 - https://busybox.net/downloads/BusyBox.html