mongoose.1 7.6 KB

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