httpd 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. If a prefix of the URI matches a redirection path,
  122. the URI is rewritten using a replacement path,
  123. and a redirect is sent to the HTTP client.
  124. If the replacement path does not specify a server name,
  125. and the request has no explicit host,
  126. then
  127. .I domain
  128. is the host name used in the redirection.
  129. The prefix can either be a domain root like
  130. .B http://system/
  131. (which matches that URL only)
  132. or a path like
  133. .B /who/rob
  134. (which matches that path no matter what
  135. the requested server),
  136. but not both:
  137. .B http://system/who/rob
  138. will never match a request.
  139. .PP
  140. Before opening any file,
  141. .I httpd
  142. looks for a file in the same directory called
  143. .BR .httplogin .
  144. If the file exists, the directory is considered
  145. locked and the client must specify a user name
  146. and password machine a pair in the file.
  147. .B .httplogin
  148. contains a list of space or newline separated tokens, each
  149. possibly delimited by single quotes. The first
  150. is a domain name presented to the HTTP client.
  151. The rest are pairs of user name and password.
  152. Thus, there can be many user name/password pairs
  153. valid for a directory.
  154. .PP
  155. If the requested URI begins with
  156. .BI /magic/ server /\f1,
  157. .I httpd
  158. executes the file
  159. .BI /bin/ip/httpd/ server
  160. to finish servicing the request.
  161. .IR Method
  162. and
  163. .IR version
  164. are those received on the first line of the request.
  165. .I Uri
  166. is the remaining portion of the requested URI.
  167. .I Inbuf
  168. contains the rest of the bytes read by the server,
  169. and
  170. .I netdir
  171. is the network directory for the connection.
  172. There are routines for processing command arguments,
  173. parsing headers, etc. in the httpd library,
  174. .BR /sys/src/cmd/ip/httpd/libhttpd.a.$O .
  175. See
  176. .B httpd.h
  177. in that directory and existing magic commands for more details.
  178. .PP
  179. .I Mirror
  180. is a trivial server that just returns the method, URI, any search,
  181. the headers, and the message body sent by the client.
  182. .PP
  183. .I Save
  184. writes a line to
  185. .BI /usr/web/save/ uri .data
  186. and returns the contents of
  187. .BI /usr/web/save/ uri .html.
  188. Both files must be accessible for the request to succeed.
  189. The saved line includes the current time
  190. and either the search string from a HEAD or GET
  191. or the first line of the body from a POST.
  192. It is used to record form submissions.
  193. .PP
  194. .I Imagemap
  195. processes an HTML imagemap query.
  196. It looks up a the point
  197. .I search
  198. in the image map file given by
  199. .IR uri ,
  200. and returns a redirection to the appropriate page.
  201. The map file defaults to NCSA format.
  202. Any entries after a line starting with the word
  203. .B #cern
  204. are interpreted in CERN format.
  205. .PP
  206. .I Man2html
  207. converts
  208. .IR man (6)
  209. format manual pages into html.
  210. It includes some abilities to search the manuals.
  211. .PP
  212. .I Webls
  213. produces directory listings on the fly, with
  214. output in the style of
  215. .IR ls (1).
  216. .B /sys/lib/webls.allowed
  217. and
  218. .B /sys/lib/webls.denied
  219. contain regular expressions describing
  220. what parts of
  221. .I httpd's
  222. namespace may and may not be listed, respectively.
  223. .B Webls.denied
  224. is first searched to see if access is by default
  225. denied. If so
  226. .B webls.allowed
  227. is then searched to see if access is explicitly allowed.
  228. Thus one can have very general expressions in the
  229. denied list (like
  230. .BR .* ),
  231. yet still allow exceptions. If
  232. .B webls.denied
  233. does not exist or is unreadable,
  234. all accesses are assumed to be denied unless
  235. explicitly allowed in
  236. .B webls.allowed.
  237. .PP
  238. Other sites will note that if neither
  239. .B webls.denied
  240. nor
  241. .B webls.allowed
  242. exist, any portion of
  243. .I httpd's
  244. namespace can be listed (however,
  245. .I webls
  246. will always endeavor to prevent listing of `.' and `..').
  247. If
  248. .B webls.allowed
  249. exists but
  250. .B webls.denied
  251. does not, any directory to be listed must be described
  252. by a regular expression in
  253. .BR webls.allowed .
  254. Similarly, if
  255. .B webls.denied
  256. exists but
  257. .B webls.allowed
  258. does not, any directory to be listed must
  259. .I not
  260. be described by a regular expression in
  261. .BR webls.denied .
  262. If both exist, a directory is listable if either
  263. it doesn't appear in
  264. .BR webls.denied ,
  265. or it appears in both
  266. .B webls.denied
  267. and
  268. .BR webls.allowed .
  269. In other words,
  270. .B webls.allowed
  271. overrides
  272. .BR webls.denied .
  273. If a listing for a directory is requested and access
  274. is denied, or another error occurs, a simple error
  275. page is returned.
  276. .SH FILES
  277. .TF /lib/namespace.httpd
  278. .TP
  279. .B /sys/lib/mimetype
  280. content type description file
  281. .TP
  282. .B /lib/namespace.httpd
  283. default namespace file for httpd
  284. .TP
  285. .B /sys/lib/httpd.rewrite
  286. redirection file
  287. .TP
  288. .B /sys/lib/webls.allowed
  289. regular expressions describing explicitly listable pathnames; overrides webls.denied
  290. .TP
  291. .B /sys/lib/webls.denied
  292. regular expressions describing explicitly unlistable pathnames
  293. .SH SOURCE
  294. .B /sys/src/cmd/ip/httpd
  295. .SH "SEE ALSO"
  296. .I newns
  297. in
  298. .IR auth (2),
  299. .IR listen (8),
  300. .IR x509 (8)