httpd 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. .TH HTTPD 8
  2. .SH NAME
  3. httpd, mirror, save, imagemap, man2html \- 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. .SH DESCRIPTION
  73. .I Httpd
  74. serves the
  75. .I webroot
  76. directory of the file system described by
  77. .I namespace
  78. (default
  79. .BR /lib/namespace.httpd ),
  80. using version 1.1 of the HTTP protocol.
  81. It announces the service
  82. .I srvaddr
  83. (default
  84. .BR tcp!*!http ),
  85. and listens for incoming calls.
  86. If an X.509 certificate is supplied with the
  87. .B -c
  88. option, then the service is instead
  89. .BR tcp!*!https .
  90. There should already be a factotum
  91. holding the corresponding private key.
  92. .PP
  93. .I Httpd
  94. supports only the GET and HEAD methods of the HTTP protocol;
  95. some magic programs support POST as well.
  96. Persistent connections are supported for HTTP/1.1 or later clients;
  97. all connections close after a magic command is executed.
  98. The Content-type
  99. (default application/octet-stream)
  100. and Content-encoding
  101. (default binary)
  102. of a file are determined by looking for suffixes of the file name in
  103. .BR /sys/lib/mimetype .
  104. .PP
  105. Each requested URI is looked up in a redirection table, read from
  106. .BR /sys/lib/httpd.rewrite .
  107. If a prefix of the URI matches a redirection path,
  108. the URI is rewritten using a replacement path,
  109. and a redirect is sent to the HTTP client.
  110. If the replacement path does not specify a server name,
  111. and the request has no explicit host,
  112. then
  113. .I domain
  114. is the host name used in the redirection.
  115. .PP
  116. Before opening any file,
  117. .I httpd
  118. looks for a file in the same directory called
  119. .BR .httplogin .
  120. If the file exists, the directory is considered
  121. locked and the client must specify a user name
  122. and password machine a pair in the file.
  123. .B .httplogin
  124. contains a list of space or newline separated tokens, each
  125. possibly delimited by single quotes. The first
  126. is a domain name presented to the HTTP client.
  127. The rest are pairs of user name and password.
  128. Thus, there can be many user name/password pairs
  129. valid for a directory.
  130. .PP
  131. If the requested URI begins with
  132. .BI /magic/ server /\f1,
  133. .I httpd
  134. executes the file
  135. .BI /bin/ip/httpd/ server
  136. to finish servicing the request.
  137. .IR Method
  138. and
  139. .IR version
  140. are those received on the first line of the request.
  141. .I Uri
  142. is the remaining portion of the requested URI.
  143. .I Inbuf
  144. contains the rest of the bytes read by the server,
  145. and
  146. .I netdir
  147. is the network directory for the connection.
  148. There are routines for processing command arguments,
  149. parsing headers, etc. in the httpd library,
  150. .BR /sys/src/cmd/ip/httpd/libhttpd.a.$O .
  151. See
  152. .B httpd.h
  153. in that directory and existing magic commands for more details.
  154. .PP
  155. .I Mirror
  156. is a trivial server that just returns the method, URI, any search,
  157. the headers, and the message body sent by the client.
  158. .PP
  159. .I Save
  160. writes a line to
  161. .BI /usr/web/save/ uri .data
  162. and returns the contents of
  163. .BI /usr/web/save/ uri .html.
  164. Both files must be accessible for the request to succeed.
  165. The saved line includes the current time
  166. and either the search string from a HEAD or GET
  167. or the first line of the body from a POST.
  168. It is used to record form submissions.
  169. .PP
  170. .I Imagemap
  171. processes an HTML imagemap query.
  172. It looks up a the point
  173. .I search
  174. in the image map file given by
  175. .IR uri ,
  176. and returns a redirection to the appropriate page.
  177. The map file defaults to NCSA format.
  178. Any entries after a line starting with the word
  179. .B #cern
  180. are interpreted in CERN format.
  181. .PP
  182. .I Man2html
  183. converts
  184. .IR man (6)
  185. format manual pages into html.
  186. It includes some abilities to search the manuals.
  187. .SH FILES
  188. .TF /lib/namespace.httpd
  189. .TP
  190. .B /sys/lib/mimetype
  191. content type description file
  192. .TP
  193. .B /lib/namespace.httpd
  194. default namespace file for httpd
  195. .TP
  196. .B /sys/lib/httpd.rewrite
  197. redirection file
  198. .SH SOURCE
  199. .B /sys/src/cmd/ip/httpd
  200. .SH "SEE ALSO"
  201. .I newns
  202. in
  203. .IR auth (2),
  204. .IR listen (8),
  205. .IR x509 (8)