]> git.lizzy.rs Git - plan9front.git/blob - sys/man/8/rc-httpd
git(1): "see also" consistency (thanks sirjofri)
[plan9front.git] / sys / man / 8 / rc-httpd
1 .TH RC-HTTPD 8
2 .SH NAME
3 rc-httpd \- HTTP server
4 .SH SYNOPSIS
5 .B rc-httpd/rc-httpd
6 .SH DESCRIPTION
7 .I Rc-httpd
8 serves the requested file or an index of files found under
9 a website's root directory, or, in the case of CGI, executes
10 a specified CGI program.
11 .SH CONFIGURATION
12 .PP
13 As all pieces of
14 .B rc-httpd
15 are shell scripts, configuration is achieved by setting variables
16 and adding, removing or modifying commands in various files.
17 .PP
18 .B rc-httpd
19 .PP
20 .I rc_httpd_dir
21 must be set to the root of the rc-httpd installation,
22 the directory containing the rc-httpd script.
23 .PP
24 .I path
25 must include
26 .I  rc_httpd_dir/handlers
27 ahead of the base system's path elements.
28 .PP
29 .I cgi_path
30 is substituted for
31 .I path
32 when cgi scripts are run. (Be sure
33 to set
34 .I path
35 back in rc-based cgi scripts.)
36 .PP
37 .I extra_headers
38 is an optional list of strings to emit when sending http headers.
39 .PP
40 .I SERVER_PORT
41 is the port HTTP is to be served on.
42 .PP
43 .B select-handler
44 .PP
45 .I PATH_INFO
46 is the location relative to the website's root directory of the file
47 to be displayed.
48 Typically, the
49 .I location
50 from the incoming request is honored.
51 .PP
52 .I FS_ROOT
53 sets the root directory of the website.
54 .PP
55 .I NOINDEXFILE
56 instructs the
57 .B dir-index
58 module not to
59 look for
60 .B index.html
61 files, otherwise if an
62 .B index.html
63 file is found
64 .B dir-index
65 will exec
66 .B serve-static
67 to serve the file.  At present there
68 is no module to serve an index file but not a directory.
69 .PP
70 If you do not want directory indexing at all, replace
71 .B static-or-index
72 with
73 .B serve-static,
74 which will report 503 forbidden for directories.
75 .PP
76 Multiple virtual hosts may be configured by creating conditional
77 statements that act upon the
78 .I SERVER_NAME
79 variable. Fine-grained control of specific request strings may
80 be configured via a similar method acting upon the
81 .I location
82 and/or other variables.
83 .SH EXAMPLES
84 The following examples demonstrate possible ways to configure
85 .BR select-handler.
86 .PP
87 Serve static files:
88 .RS
89 .EX
90 if(~ $SERVER_NAME 9front.org){
91         PATH_INFO=$location
92         FS_ROOT=/usr/sl/www/$SERVER_NAME
93         exec static-or-index
94 }
95 .EE
96 .RE
97 .PP
98 CGI:
99 .RS
100 .EX
101 if(~ $SERVER_NAME *cat-v.org){
102         PATH_INFO=$location
103         FS_ROOT=/usr/sl/www/werc/sites/$SERVER_NAME
104         exec static-or-cgi /usr/sl/www/werc/bin/werc.rc
105 }
106 .EE
107 .RE
108 .PP
109 Custom error message for a denied URL:
110 .RS
111 .EX
112 fn do_error{
113         do_log $1
114         echo 'HTTP/1.1 '^$1^$cr
115         emit_extra_headers
116         echo 'Content-type: text/html'^$cr
117         echo $cr
118         echo '<html>
119 <head>
120 <title>'^$1^'</title>
121 </head>
122 <body>
123 <h1>'^$1^'</h1>'
124         echo $2
125         echo '<p><i>rc-httpd at' $SERVER_NAME '</i>'
126         echo '
127         </body>
128         </html>
129         '
130 }
131 if(~ $location /v8.tar.bz2){
132         do_error '27b/6'
133         exit
134 }
135 .EE
136 .RE
137 .SH STARTUP
138 .I Rc-httpd
139 is run from a file in the directory scanned by
140 .IR listen (8),
141 or called as an argument to aux/listen1.
142 The program's standard error may be captured to a log file:
143 .RS
144 .EX
145 exec /rc/bin/rc-httpd/rc-httpd >>[2]/sys/log/www
146 .EE
147 .RE
148 .SH FILES
149 .TF /sys/lib/httpd.rewrite
150 .TP
151 .B /rc/bin/rc-httpd/rc-httpd
152 .TP
153 .B /rc/bin/rc-httpd/select-handler
154 .TP
155 .B /rc/bin/rc-httpd/handlers/cgi
156 .TP
157 .B /rc/bin/rc-httpd/handlers/dir-index
158 .TP
159 .B /rc/bin/rc-httpd/handlers/error
160 .TP
161 .B /rc/bin/rc-httpd/handlers/redirect
162 .TP
163 .B /rc/bin/rc-httpd/handlers/serve-static
164 .TP
165 .B /rc/bin/rc-httpd/handlers/static-or-cgi
166 .TP
167 .B /rc/bin/rc-httpd/handlers/static-or-index
168 .TP
169 .B /rc/bin/service/tcp80
170 .TP
171 .B /sys/log/www
172 .SH SOURCE
173 .B /rc/bin/rc-httpd
174 .SH "SEE ALSO"
175 .IR rc (1),
176 .IR listen (8)
177 .SH HISTORY
178 .I Rc-httpd
179 first appeared in 9front (February, 2013).