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