httpfile(1)

NAME
httpfile - A simple HTTP server for publishing static content

SYNOPSIS
httpfile [ options ] root

DESCRIPTION
httpfile is HTTP server derived from publicfile (https://cr.yp.to/publicfile.html)

OPTIONS

-v  Enable verbose mode. Multiple -v options increase the verbosity. The maximum is 3.

-t seconds
    Set the 'request timeout' to seconds seconds. When httpfile reads HTTP request, the 'request timeout' covers time when the entire HTTP request is loaded. (default 30).

-T seconds
    Set the 'write timeout' to the network to seconds seconds. When httpfile sends a HTTP response, the 'write timeout' is set for each write(). (default 60).

-u user
    Run httpfile under a specified user's uid and gid.

-h custom header
    Add custom header to the HTTP response. The maximum is 8 custom headers.

root
    run chrooted in the directory root.

ENVIRONMENT

UID/GID run under the uid and gid specified by the $UID and $GID environment variables

INTERFACE

most httpfile properties are inherited from publicfile-0.76
    Normally httpfile is run under tcpserver/inetd/systemd/... to handle HTTP connections from hosts around the Internet.
    httpfile prints requested public files from the root directory hierarchy see FILE HANDLING. Normally root is /var/www/httpfile.
    httpfile accepts GET and HEAD requests and prohibits POST, PUT, DELETE, ...
    httpfile HTTP/1.0, and HTTP/1.1 formats.
    httpfile has exact-prefix support for If-Modified-Since: it uses code 304 if the Last-Modified contents are an exact prefix of the If-Modified-Since contents.
    httpfile support basic authentication see BASIC AUTHORIZATION.
    httpfile accepts range requests.

FILE HANDLING
    A request for http://<host>/<file> refers to the file named ./<host>/<file> inside the root directory hierarchy, if <file> does not end with a slash.
    A request for http://<host>/<dir>/ refers to the file named ./<host>/<dir>/index.html.
    httpfile always converts the host name v to lowercase. If HTTP/1.0 requests do not specify a host name; in this case httpfile uses the host name '0'.
    A request for http://<host>/<dir> is redirected to http://<host>/<dir>/, which refers to the file named ./<host>/<dir>/index.html.

    httpfile does not allow dots immediately after slashes in file names. It changes these dots to colons before attempting to open the file.

BASIC AUTHORIZATION
    httpfile supports basic authentication using a special file (e.g. named pipe) trick.
    A request for http://<host>/<dir>/<specialfile> returns HTTP response 401. Browser than sends request with authorization header "Authorization: Basic <base64_credentials>".
    Then request for http://<host>/<file> refers to the file named ./@<base64_credentials_without_'='_pading>/<host>/<file>.

EXAMPLES

Run httpfile using tcpserver/busybox/inetd on port 80 under user nobody and with root directory /var/www/httpfile.
    tcpserver -HRDl0 0 80 httpfile -u nobody /var/www/httpfile
    busybox tcpsvd 0 80 httpfile -u nobody /var/www/httpfile
    inetd.conf line: http stream tcp nowait root /usr/bin/httpfile httpfile -u nobody /var/www/httpfile

Add headers to prohibit browser caching
     ... httpfile -h 'Expires: -1' -h 'Cache-Control: must-revalidate, private' ...

Add HSTS header
     ... httpfile -h 'Strict-Transport-Security: max-age=63072000; includeSubDomains; preload' ...

DIFFERENCE COMPARED TO PUBLICFILE
    source code rewritten from scratch
    removed ftpd
    added range support
    added 301 redirect for directories
    added basic authentication as a simple protection against robots
    name changed to 'httpfile'

SEE ALSO
systemd.socket(5), inetd(8), tcpserver(1)

https://cr.yp.to/publicfile.html