httpd 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. .TH HTTPD 8
  2. .SH NAME
  3. httpd, mirror, save, imagemap, man2html, webls \- HTTP server
  4. .SH SYNOPSIS
  5. .PP
  6. .B ip/httpd/httpd
  7. .RB [ -a
  8. .IR srvaddr ]
  9. .RB [ -c
  10. .IR cert ]
  11. .RB [ -d
  12. .IR domain ]
  13. .RB [ -n
  14. .IR namespace ]
  15. .RB [ -w
  16. .IR webroot ]
  17. .PP
  18. .B ip/httpd/mirror
  19. .RB [ -b
  20. .IR inbuf ]
  21. .RB [ -d
  22. .IR domain ]
  23. .RB [ -r
  24. .IR remoteip ]
  25. .RB [ -w
  26. .IR webroot ]
  27. .RB [ -N
  28. .IR netdir ]
  29. .I method version uri
  30. .RI [ search ]
  31. .PP
  32. .B ip/httpd/save
  33. .RB [ -b
  34. .IR inbuf ]
  35. .RB [ -d
  36. .IR domain ]
  37. .RB [ -r
  38. .IR remoteip ]
  39. .RB [ -w
  40. .IR webroot ]
  41. .RB [ -N
  42. .IR netdir ]
  43. .I method version uri
  44. .RI [ search ]
  45. .PP
  46. .B ip/httpd/imagemap
  47. .RB [ -b
  48. .IR inbuf ]
  49. .RB [ -d
  50. .IR domain ]
  51. .RB [ -r
  52. .IR remoteip ]
  53. .RB [ -w
  54. .IR webroot ]
  55. .RB [ -N
  56. .IR netdir ]
  57. .I method version uri
  58. .PP
  59. .B ip/httpd/man2html
  60. .RB [ -b
  61. .IR inbuf ]
  62. .RB [ -d
  63. .IR domain ]
  64. .RB [ -r
  65. .IR remoteip ]
  66. .RB [ -w
  67. .IR webroot ]
  68. .RB [ -N
  69. .IR netdir ]
  70. .I method version uri
  71. .RI [ search ]
  72. .PP
  73. .B ip/httpd/webls
  74. .RB [ -b
  75. .IR inbuf ]
  76. .RB [ -d
  77. .IR domain ]
  78. .RB [ -r
  79. .IR remoteip ]
  80. .RB [ -w
  81. .IR webroot ]
  82. .RB [ -N
  83. .IR netdir ]
  84. .I method version uri
  85. .RI [ search ]
  86. .SH DESCRIPTION
  87. .I Httpd
  88. serves the
  89. .I webroot
  90. directory of the file system described by
  91. .I namespace
  92. (default
  93. .BR /lib/namespace.httpd ),
  94. using version 1.1 of the HTTP protocol.
  95. It announces the service
  96. .I srvaddr
  97. (default
  98. .BR tcp!*!http ),
  99. and listens for incoming calls.
  100. If an X.509 certificate is supplied with the
  101. .B -c
  102. option, then the service is instead
  103. .BR tcp!*!https .
  104. There should already be a factotum
  105. holding the corresponding private key.
  106. .PP
  107. .I Httpd
  108. supports only the GET and HEAD methods of the HTTP protocol;
  109. some magic programs support POST as well.
  110. Persistent connections are supported for HTTP/1.1 or later clients;
  111. all connections close after a magic command is executed.
  112. The Content-type
  113. (default application/octet-stream)
  114. and Content-encoding
  115. (default binary)
  116. of a file are determined by looking for suffixes of the file name in
  117. .BR /sys/lib/mimetype .
  118. .PP
  119. Each requested URI is looked up in a redirection table, read from
  120. .BR /sys/lib/httpd.rewrite .
  121. The first field of each line is a URI;
  122. the second a replacement path.
  123. If a prefix of the URI matches a redirection path,
  124. the URI is rewritten using the corresponding replacement path,
  125. and a redirect is sent to the HTTP client.
  126. If the replacement path does not specify a server name,
  127. and the request has no explicit host,
  128. then
  129. .I domain
  130. is the host name used in the redirection.
  131. The prefix can either be a domain root like
  132. .B http://system/
  133. (which matches that URL only)
  134. or a path like
  135. .B /who/rob
  136. (which matches that path no matter what
  137. the requested server),
  138. but not both:
  139. .B http://system/who/rob
  140. will never match a request.
  141. .I Httpd
  142. handles replacements prefixed with
  143. .B @
  144. internally,
  145. treating the request as if it were for the replacement
  146. (without the
  147. .BR @ )
  148. but not informing the client of the rewritten name.
  149. .PP
  150. Before opening any file,
  151. .I httpd
  152. looks for a file in the same directory called
  153. .BR .httplogin .
  154. If the file exists, the directory is considered
  155. locked and the client must specify a user name
  156. and password matching a pair in the file.
  157. .B .httplogin
  158. contains a list of space or newline separated tokens, each
  159. possibly delimited by single quotes. The first
  160. is a domain name presented to the HTTP client.
  161. The rest are pairs of user name and password.
  162. Thus, there can be many user name/password pairs
  163. valid for a directory.
  164. .PP
  165. If the requested URI begins with
  166. .BI /magic/ server /\f1,
  167. .I httpd
  168. executes the file
  169. .BI /bin/ip/httpd/ server
  170. to finish servicing the request.
  171. .IR Method
  172. and
  173. .IR version
  174. are those received on the first line of the request.
  175. .I Uri
  176. is the remaining portion of the requested URI.
  177. .I Inbuf
  178. contains the rest of the bytes read by the server,
  179. and
  180. .I netdir
  181. is the network directory for the connection.
  182. There are routines for processing command arguments,
  183. parsing headers, etc. in the httpd library,
  184. .BR /sys/src/cmd/ip/httpd/libhttpd.a.$O .
  185. See
  186. .B httpd.h
  187. in that directory and existing magic commands for more details.
  188. .PP
  189. .I Mirror
  190. is a trivial server that just returns the method, URI, any search,
  191. the headers, and the message body sent by the client.
  192. .PP
  193. .I Save
  194. writes a line to
  195. .BI /usr/web/save/ uri .data
  196. and returns the contents of
  197. .BI /usr/web/save/ uri .html.
  198. Both files must be accessible for the request to succeed.
  199. The saved line includes the current time
  200. and either the search string from a HEAD or GET
  201. or the first line of the body from a POST.
  202. It is used to record form submissions.
  203. .PP
  204. .I Imagemap
  205. processes an HTML imagemap query.
  206. It looks up a the point
  207. .I search
  208. in the image map file given by
  209. .IR uri ,
  210. and returns a redirection to the appropriate page.
  211. The map file defaults to NCSA format.
  212. Any entries after a line starting with the word
  213. .B #cern
  214. are interpreted in CERN format.
  215. .PP
  216. .I Man2html
  217. converts
  218. .IR man (6)
  219. format manual pages into html.
  220. It includes some abilities to search the manuals.
  221. .PP
  222. .I Webls
  223. produces directory listings on the fly, with
  224. output in the style of
  225. .IR ls (1).
  226. .B /sys/lib/webls.allowed
  227. and
  228. .B /sys/lib/webls.denied
  229. contain regular expressions describing
  230. what parts of
  231. .I httpd's
  232. namespace may and may not be listed, respectively.
  233. .B Webls.denied
  234. is first searched to see if access is by default
  235. denied. If so
  236. .B webls.allowed
  237. is then searched to see if access is explicitly allowed.
  238. Thus one can have very general expressions in the
  239. denied list (like
  240. .BR .* ),
  241. yet still allow exceptions. If
  242. .B webls.denied
  243. does not exist or is unreadable,
  244. all accesses are assumed to be denied unless
  245. explicitly allowed in
  246. .B webls.allowed.
  247. .PP
  248. Other sites will note that if neither
  249. .B webls.denied
  250. nor
  251. .B webls.allowed
  252. exist, any portion of
  253. .I httpd's
  254. namespace can be listed (however,
  255. .I webls
  256. will always endeavor to prevent listing of `.' and `..').
  257. If
  258. .B webls.allowed
  259. exists but
  260. .B webls.denied
  261. does not, any directory to be listed must be described
  262. by a regular expression in
  263. .BR webls.allowed .
  264. Similarly, if
  265. .B webls.denied
  266. exists but
  267. .B webls.allowed
  268. does not, any directory to be listed must
  269. .I not
  270. be described by a regular expression in
  271. .BR webls.denied .
  272. If both exist, a directory is listable if either
  273. it doesn't appear in
  274. .BR webls.denied ,
  275. or it appears in both
  276. .B webls.denied
  277. and
  278. .BR webls.allowed .
  279. In other words,
  280. .B webls.allowed
  281. overrides
  282. .BR webls.denied .
  283. If a listing for a directory is requested and access
  284. is denied, or another error occurs, a simple error
  285. page is returned.
  286. .SH FILES
  287. .TF /sys/lib/httpd.rewrite
  288. .TP
  289. .B /sys/lib/mimetype
  290. content type description file
  291. .TP
  292. .B /lib/namespace.httpd
  293. default namespace file for httpd
  294. .TP
  295. .B /sys/lib/httpd.rewrite
  296. redirection file
  297. .TP
  298. .B /sys/lib/webls.allowed
  299. regular expressions describing explicitly listable pathnames; overrides
  300. .B webls.denied
  301. .TP
  302. .B /sys/lib/webls.denied
  303. regular expressions describing explicitly unlistable pathnames
  304. .SH SOURCE
  305. .B /sys/src/cmd/ip/httpd
  306. .SH "SEE ALSO"
  307. .I newns
  308. in
  309. .IR auth (2),
  310. .IR listen (8),
  311. .IR rsa (8)