1mongoose(1) BSD General Commands Manual mongoose(1)
2
4 mongoose — lightweight web server
5
7 mongoose [config_file] [OPTIONS]
8 mongoose -A htpasswd_file domain_name user_name password
9
11 mongoose is small, fast and easy to use web server with CGI, SSL, MD5
12 authorization, and basic SSI support.
13
14 mongoose does not detach from terminal, and uses current working direc‐
15 tory as the web root, unless -r option is specified. It is possible to
16 specify multiple ports to listen on. For example, to make mongoose listen
17 on HTTP port 80 and HTTPS port 443, one should start it as: mongoose -s
18 cert.pem -p 80,443s
19
20 Unlike other web servers, mongoose does not require CGI scripts be put in
21 a special directory. CGI scripts can be anywhere. CGI (and SSI) files are
22 recognized by the file name pattern. mongoose uses shell-like glob pat‐
23 terns with the following syntax:
24 ** Matches everything
25 * Matches everything but slash character, '/'
26 ? Matches any character
27 $ Matches the end of the string
28 | Matches if pattern on the left side or the right side matches.
29 Pattern on the left side is matched first
30 All other characters in the pattern match themselves.
31
32 If no arguments are given, mongoose searches for a configuration file
33 called "mongoose.conf" in the same directory where mongoose binary is
34 located. Alternatively, a file name could be specified in the command
35 line. Format of the configuration file is the same as for the command
36 line options except that each option must be specified on a separate
37 line, leading dashes for option names must be omitted. Lines beginning
38 with '#' and empty lines are ignored.
39
41 -A htpasswd_file domain_name user_name password
42 Add/edit user's password in the passwords file. Deleting users
43 can be done with any text editor. Functionality is similar to
44 Apache's htdigest utility.
45
46 -C cgi_pattern
47 All files that fully match cgi_pattern are treated as CGI.
48 Default pattern allows CGI files be anywhere. To restrict CGIs to
49 certain directory, use e.g. "-C /cgi-bin/**.cgi". Default:
50 "**.cgi$|**.pl$|**.php$"
51
52 -E cgi_environment
53 Extra environment variables to be passed to the CGI script in
54 addition to standard ones. The list must be comma-separated list
55 of X=Y pairs, like this: "VARIABLE1=VALUE1,VARIABLE2=VALUE2".
56 Default: ""
57
58 -G put_delete_passwords_file
59 PUT and DELETE passwords file. This must be specified if PUT or
60 DELETE methods are used. Default: ""
61
62 -I cgi_interpreter
63 Use cgi_interpreter as a CGI interpreter for all CGI scripts
64 regardless script extension. Mongoose decides which interpreter
65 to use by looking at the first line of a CGI script. Default:
66 "".
67
68 -M max_request_size
69 Maximum HTTP request size in bytes. Default: "16384"
70
71 -P protect_uri
72 Comma separated list of URI=PATH pairs, specifying that given
73 URIs must be protected with respected password files. Default: ""
74
75 -R authentication_domain
76 Authorization realm. Default: "mydomain.com"
77
78 -S ssi_pattern
79 All files that fully match ssi_pattern are treated as SSI.
80 Unknown SSI directives are silently ignored. Currently, two SSI
81 directives are supported, "include" and "exec". Default:
82 "**.shtml$|**.shtm$"
83
84 -a access_log_file
85 Access log file. Default: "", no logging is done.
86
87 -d enable_directory_listing
88 Enable/disable directory listing. Default: "yes"
89
90 -e error_log_file
91 Error log file. Default: "", no errors are logged.
92
93 -g global_passwords_file
94 Location of a global passwords file. If set, per-directory
95 .htpasswd files are ignored, and all requests must be authorised
96 against that file. Default: ""
97
98 -i index_files
99 Comma-separated list of files to be treated as directory index
100 files. Default: "index.html,index.htm,index.cgi"
101
102 -l access_control_list
103 Specify access control list (ACL). ACL is a comma separated list
104 of IP subnets, each subnet is prepended by '-' or '+' sign. Plus
105 means allow, minus means deny. If subnet mask is omitted, like
106 "-1.2.3.4", then it means single IP address. Mask may vary from 0
107 to 32 inclusive. On each request, full list is traversed, and
108 last match wins. Default setting is to allow all. For example, to
109 allow only 192.168/16 subnet to connect, run "mongoose
110 -0.0.0.0/0,+192.168/16". Default: ""
111
112 -m extra_mime_types
113 Extra mime types to recognize, in form "extension1=type1,exten‐
114 sion2=type2,...". Extension must include dot. Example: "mongoose
115 -m .cpp=plain/text,.java=plain/text". Default: ""
116
117 -p listening_ports
118 Comma-separated list of ports to listen on. If the port is SSL, a
119 letter 's' must be appeneded, for example, "-p 80,443s" will open
120 port 80 and port 443, and connections on port 443 will be SSL-ed.
121 It is possible to specify an IP address to bind to. In this case,
122 an IP address and a colon must be prepended to the port number.
123 For example, to bind to a loopback interface on port 80 and to
124 all interfaces on HTTPS port 443, use "mongoose -p
125 127.0.0.1:80,443s". Default: "8080"
126
127 -r document_root
128 Location of the WWW root directory. Default: "."
129
130 -s ssl_certificate
131 Location of SSL certificate file. Default: ""
132
133 -t num_threads
134 Number of worker threads to start. Default: "10"
135
136 -u run_as_user
137 Switch to given user's credentials after startup. Default: ""
138
139 -w url_rewrite_patterns
140 Comma-separated list of URL rewrites in the form of "pattern=sub‐
141 stitution,..." If the "pattern" matches some prefix of the
142 requested URL, then matched prefix gets substituted with "substi‐
143 tution". For example, "-w /config=/etc,**.doc|**.rtf=/cgi-
144 bin/handle_doc.cgi" will serve all URLs that start with "/config"
145 from the "/etc" directory, and call handle_doc.cgi script for
146 .doc and .rtf file requests. If some pattern matches, no further
147 matching/substitution is performed (first matching pattern wins).
148 Default: ""
149
151 mongoose was designed to be embeddable into C/C++ applications. Since the
152 source code is contained in single C file, it is fairly easy to embed it
153 and follow the updates. Please refer to http://code.google.com/p/mongoose
154 for details.
155
157 mongoose -r /var/www -s /etc/cert.pem -p 8080,8043s
158 Start serving files from /var/www. Listen on port 8080 for HTTP,
159 and 8043 for HTTPS connections. Use /etc/cert.pem as SSL cer‐
160 tificate file.
161
162 mongoose -l -0.0.0.0/0,+10.0.0.0/8,+1.2.3.4
163 Deny connections from everywhere, allow only IP address 1.2.3.4
164 and all IP addresses from 10.0.0.0/8 subnet to connect.
165
166 mongoose -w **=/my/script.cgi
167 Invoke /my/script.cgi for every incoming request, regardless of
168 the URL.
169
171 mongoose is licensed under the terms of the MIT license.
172
174 Sergey Lyubka <valenok@gmail.com>.
175
176 Aug 31, 2010