2010-05-04 04:46:42 +08:00
|
|
|
.\" Process this file with
|
|
|
|
.\" groff -man -Tascii mongoose.1
|
|
|
|
.\" $Id: mongoose.1,v 1.12 2008/11/29 15:32:42 drozd Exp $
|
2010-08-31 00:13:53 +08:00
|
|
|
.Dd Aug 31, 2010
|
2010-05-04 04:46:42 +08:00
|
|
|
.Dt mongoose 1
|
|
|
|
.Sh NAME
|
|
|
|
.Nm mongoose
|
|
|
|
.Nd lightweight web server
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Nm
|
|
|
|
.Op Ar config_file
|
2010-08-31 00:13:53 +08:00
|
|
|
.Op Ar OPTIONS
|
|
|
|
.Nm
|
2010-05-04 04:46:42 +08:00
|
|
|
.Fl A Ar htpasswd_file domain_name user_name password
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
.Nm
|
2010-08-31 00:13:53 +08:00
|
|
|
is small, fast and easy to use web server with CGI, SSL, MD5 authorization,
|
|
|
|
and basic SSI support.
|
2010-05-04 04:46:42 +08:00
|
|
|
.Pp
|
|
|
|
.Nm
|
|
|
|
does not detach from terminal, and uses current working directory
|
|
|
|
as the web root, unless
|
2010-08-31 00:13:53 +08:00
|
|
|
.Fl r
|
2010-05-04 04:46:42 +08:00
|
|
|
option is specified.
|
2010-08-31 00:13:53 +08:00
|
|
|
It is possible to specify multiple ports to listen on. For example, to make
|
|
|
|
mongoose listen on HTTP port 80 and HTTPS port 443, one should start it as:
|
2010-05-04 04:46:42 +08:00
|
|
|
.Nm
|
2010-08-31 00:13:53 +08:00
|
|
|
.Fl s Ar cert.pem Fl p Ar 80,443s
|
2010-05-04 04:46:42 +08:00
|
|
|
.Pp
|
|
|
|
Unlike other web servers,
|
|
|
|
.Nm
|
2012-01-24 17:30:01 +08:00
|
|
|
does not require CGI scripts be put in a special directory. CGI scripts can
|
|
|
|
be anywhere. CGI (and SSI) files are recognized by the file name pattern.
|
|
|
|
.Nm
|
|
|
|
uses shell-like glob patterns with the following syntax:
|
|
|
|
.Bl -tag -compact -width indent
|
|
|
|
.It **
|
|
|
|
Matches everything
|
|
|
|
.It *
|
|
|
|
Matches everything but slash character, '/'
|
|
|
|
.It ?
|
|
|
|
Matches any character
|
2012-01-26 11:21:51 +08:00
|
|
|
.It $
|
|
|
|
Matches the end of the string
|
2012-01-24 17:30:01 +08:00
|
|
|
.It |
|
|
|
|
Matches if pattern on the left side or the right side matches. Pattern on the
|
|
|
|
left side is matched first
|
|
|
|
.El
|
|
|
|
All other characters in the pattern match themselves.
|
2010-05-04 04:46:42 +08:00
|
|
|
.Pp
|
2010-08-31 00:13:53 +08:00
|
|
|
If no arguments are given,
|
2010-05-04 04:46:42 +08:00
|
|
|
.Nm
|
2010-08-31 00:13:53 +08:00
|
|
|
searches for a configuration file called "mongoose.conf" in the same directory
|
|
|
|
where mongoose binary is located. Alternatively, a file name could be
|
|
|
|
specified in the command line. Format of the configuration file is the same
|
|
|
|
as for the command line options except that each option must be specified
|
|
|
|
on a separate line, leading dashes for option names must be omitted.
|
|
|
|
Lines beginning with '#' and empty lines are ignored.
|
2010-05-04 04:46:42 +08:00
|
|
|
.Pp
|
|
|
|
.Sh OPTIONS
|
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Fl A Ar htpasswd_file domain_name user_name password
|
|
|
|
Add/edit user's password in the passwords file. Deleting users can be done
|
2010-08-31 00:13:53 +08:00
|
|
|
with any text editor. Functionality is similar to Apache's
|
2010-05-04 04:46:42 +08:00
|
|
|
.Ic htdigest
|
|
|
|
utility.
|
2012-01-24 17:30:01 +08:00
|
|
|
.It Fl C Ar cgi_pattern
|
|
|
|
All files that fully match cgi_pattern are treated as CGI.
|
|
|
|
Default pattern allows CGI files be
|
|
|
|
anywhere. To restrict CGIs to certain directory, use e.g. "-C /cgi-bin/**.cgi".
|
2012-01-26 11:21:51 +08:00
|
|
|
Default: "**.cgi$|**.pl$|**.php$"
|
2010-08-31 00:13:53 +08:00
|
|
|
.It Fl E Ar cgi_environment
|
|
|
|
Extra environment variables to be passed to the CGI script in addition to
|
|
|
|
standard ones. The list must be comma-separated list of X=Y pairs, like this:
|
|
|
|
"VARIABLE1=VALUE1,VARIABLE2=VALUE2". Default: ""
|
|
|
|
.It Fl G Ar put_delete_passwords_file
|
|
|
|
PUT and DELETE passwords file. This must be specified if PUT or
|
|
|
|
DELETE methods are used. Default: ""
|
|
|
|
.It Fl I Ar cgi_interpreter
|
|
|
|
Use
|
|
|
|
.Ar cgi_interpreter
|
|
|
|
as a CGI interpreter for all CGI scripts regardless script extension.
|
2012-01-24 17:30:01 +08:00
|
|
|
Mongoose decides which interpreter to use by looking at
|
|
|
|
the first line of a CGI script. Default: "".
|
2010-08-31 00:13:53 +08:00
|
|
|
.It Fl P Ar protect_uri
|
|
|
|
Comma separated list of URI=PATH pairs, specifying that given URIs
|
|
|
|
must be protected with respected password files. Default: ""
|
|
|
|
.It Fl R Ar authentication_domain
|
|
|
|
Authorization realm. Default: "mydomain.com"
|
2012-01-24 17:30:01 +08:00
|
|
|
.It Fl S Ar ssi_pattern
|
|
|
|
All files that fully match ssi_pattern are treated as SSI.
|
|
|
|
Unknown SSI directives are silently ignored. Currently, two SSI directives
|
2012-01-26 11:21:51 +08:00
|
|
|
are supported, "include" and "exec". Default: "**.shtml$|**.shtm$"
|
2012-09-23 20:28:27 +08:00
|
|
|
.It Fl T Ar throttle
|
|
|
|
Limit download speed for clients.
|
|
|
|
.Ar throttle
|
|
|
|
is a comma-separated list of key=value pairs, where
|
|
|
|
key could be a '*' character (limit for all connections), a subnet in form
|
|
|
|
x.x.x.x/mask (limit for a given subnet, for example 10.0.0.0/8), or an
|
|
|
|
URI prefix pattern (limit for the set of URIs, for example /foo/**). The value
|
|
|
|
is a floating-point number of bytes per second, optionally followed by a
|
|
|
|
`k' or `m' character, meaning kilobytes and megabytes respectively. A limit
|
|
|
|
of 0 means unlimited rate. The last matching rule wins. For example,
|
|
|
|
"*=1k,10.0.0.0/8" means limit everybody to 1 kilobyte per second, but give
|
|
|
|
people from 10/8 subnet unlimited speed. Default: ""
|
2010-08-31 00:13:53 +08:00
|
|
|
.It Fl a Ar access_log_file
|
|
|
|
Access log file. Default: "", no logging is done.
|
|
|
|
.It Fl d Ar enable_directory_listing
|
|
|
|
Enable/disable directory listing. Default: "yes"
|
|
|
|
.It Fl e Ar error_log_file
|
|
|
|
Error log file. Default: "", no errors are logged.
|
|
|
|
.It Fl g Ar global_passwords_file
|
|
|
|
Location of a global passwords file. If set, per-directory .htpasswd files are
|
|
|
|
ignored, and all requests must be authorised against that file. Default: ""
|
|
|
|
.It Fl i Ar index_files
|
|
|
|
Comma-separated list of files to be treated as directory index files.
|
|
|
|
Default: "index.html,index.htm,index.cgi"
|
|
|
|
.It Fl l Ar access_control_list
|
2010-05-04 04:46:42 +08:00
|
|
|
Specify access control list (ACL). ACL is a comma separated list
|
|
|
|
of IP subnets, each subnet is prepended by '-' or '+' sign. Plus means allow,
|
|
|
|
minus means deny. If subnet mask is
|
|
|
|
omitted, like "-1.2.3.4", then it means single IP address. Mask may vary
|
|
|
|
from 0 to 32 inclusive. On each request, full list is traversed, and
|
2010-08-31 00:13:53 +08:00
|
|
|
last match wins. Default setting is to allow all. For example, to allow only
|
|
|
|
192.168/16 subnet to connect, run "mongoose -0.0.0.0/0,+192.168/16".
|
|
|
|
Default: ""
|
|
|
|
.It Fl m Ar extra_mime_types
|
|
|
|
Extra mime types to recognize, in form
|
2010-05-04 04:46:42 +08:00
|
|
|
"extension1=type1,extension2=type2,...". Extension must include dot.
|
2010-08-31 00:13:53 +08:00
|
|
|
Example: "mongoose -m .cpp=plain/text,.java=plain/text". Default: ""
|
|
|
|
.It Fl p Ar listening_ports
|
2010-05-04 04:46:42 +08:00
|
|
|
Comma-separated list of ports to listen on. If the port is SSL, a letter 's'
|
2010-08-31 00:13:53 +08:00
|
|
|
must be appeneded, for example, "-p 80,443s" will open port 80 and port 443,
|
2010-05-04 04:46:42 +08:00
|
|
|
and connections on port 443 will be SSL-ed. It is possible to specify an
|
|
|
|
IP address to bind to. In this case, an IP address and a colon must be
|
2010-08-31 00:13:53 +08:00
|
|
|
prepended to the port number. For example, to bind to a loopback interface
|
|
|
|
on port 80 and to all interfaces on HTTPS port 443, use
|
|
|
|
"mongoose -p 127.0.0.1:80,443s". Default: "8080"
|
|
|
|
.It Fl r Ar document_root
|
2012-01-24 17:30:01 +08:00
|
|
|
Location of the WWW root directory. Default: "."
|
2010-08-31 00:13:53 +08:00
|
|
|
.It Fl s Ar ssl_certificate
|
|
|
|
Location of SSL certificate file. Default: ""
|
|
|
|
.It Fl t Ar num_threads
|
|
|
|
Number of worker threads to start. Default: "10"
|
|
|
|
.It Fl u Ar run_as_user
|
|
|
|
Switch to given user's credentials after startup. Default: ""
|
2012-01-24 17:30:01 +08:00
|
|
|
.It Fl w Ar url_rewrite_patterns
|
|
|
|
Comma-separated list of URL rewrites in the form of
|
|
|
|
"pattern=substitution,..." If the "pattern" matches some prefix
|
|
|
|
of the requested URL, then matched prefix gets substituted with "substitution".
|
2012-06-07 22:08:35 +08:00
|
|
|
For example, "-w /config=/etc,**.doc|**.rtf=/path/to/cgi-bin/handle_doc.cgi"
|
2012-01-24 17:30:01 +08:00
|
|
|
will serve all URLs that start with "/config" from the "/etc" directory, and
|
2012-02-21 02:43:26 +08:00
|
|
|
call handle_doc.cgi script for .doc and .rtf file requests. If some pattern
|
|
|
|
matches, no further matching/substitution is performed
|
2012-06-07 22:08:35 +08:00
|
|
|
(first matching pattern wins). Use full paths in substitutions. Default: ""
|
2012-08-14 23:06:10 +08:00
|
|
|
.It Fl x Ar hide_files_patterns
|
|
|
|
A prefix pattern for the files to hide. Files that match the pattern will not
|
|
|
|
show up in directory listing and return 404 Not Found if requested. Default: ""
|
2010-05-04 04:46:42 +08:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
.Sh EMBEDDING
|
|
|
|
.Nm
|
|
|
|
was designed to be embeddable into C/C++ applications. Since the
|
2010-08-31 00:13:53 +08:00
|
|
|
source code is contained in single C file, it is fairly easy to embed it
|
|
|
|
and follow the updates. Please refer to http://code.google.com/p/mongoose
|
2010-05-04 04:46:42 +08:00
|
|
|
for details.
|
|
|
|
.Pp
|
|
|
|
.Sh EXAMPLES
|
|
|
|
.Bl -tag -width indent
|
2012-01-24 17:30:01 +08:00
|
|
|
.It Nm Fl r Ar /var/www Fl s Ar /etc/cert.pem Fl p Ar 8080,8043s
|
|
|
|
Start serving files from /var/www. Listen on port 8080 for HTTP, and 8043
|
|
|
|
for HTTPS connections. Use /etc/cert.pem as SSL certificate file.
|
2010-08-31 00:13:53 +08:00
|
|
|
.It Nm Fl l Ar -0.0.0.0/0,+10.0.0.0/8,+1.2.3.4
|
2010-05-04 04:46:42 +08:00
|
|
|
Deny connections from everywhere, allow only IP address 1.2.3.4 and
|
|
|
|
all IP addresses from 10.0.0.0/8 subnet to connect.
|
2012-06-07 22:08:35 +08:00
|
|
|
.It Nm Fl w Ar **=/usr/bin/script.cgi
|
|
|
|
Invoke /usr/bin/script.cgi for every incoming request, regardless of the URL.
|
2010-05-04 04:46:42 +08:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
.Sh COPYRIGHT
|
|
|
|
.Nm
|
|
|
|
is licensed under the terms of the MIT license.
|
|
|
|
.Sh AUTHOR
|
|
|
|
.An Sergey Lyubka Aq valenok@gmail.com .
|