summaryrefslogtreecommitdiff
path: root/usr.sbin/httpd/httpd.conf.5
blob: 28ba39346ca0eb7a97dd8c164e3fac453a70fc0c (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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
.\"	$OpenBSD: httpd.conf.5,v 1.26 2014/08/05 18:01:10 reyk Exp $
.\"
.\" Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: August 5 2014 $
.Dt HTTPD.CONF 5
.Os
.Sh NAME
.Nm httpd.conf
.Nd HTTP daemon configuration file
.Sh DESCRIPTION
.Nm
is the configuration file for the HTTP daemon,
.Xr httpd 8 .
.Sh SECTIONS
.Nm
is divided into four main sections:
.Bl -tag -width xxxx
.It Sy Macros
User-defined variables may be defined and used later, simplifying the
configuration file.
.It Sy Global Configuration
Global settings for
.Xr httpd 8 .
.It Sy Servers
Listening HTTP web servers.
.It Sy Types
Media types and extensions.
.El
.Pp
Within the sections,
a host
.Ar address
can be specified by IPv4 address, IPv6 address, interface name,
interface group, or DNS hostname.
If the address is an interface name,
.Xr httpd 8
will look up the first IPv4 address and any other IPv4 and IPv6
addresses of the specified network interface.
A
.Ar port
can be specified by number or name.
The port name to number mappings are found in the file
.Pa /etc/services ;
see
.Xr services 5
for details.
.Pp
The current line can be extended over multiple lines using a backslash
.Pq Sq \e .
Comments can be put anywhere in the file using a hash mark
.Pq Sq # ,
and extend to the end of the current line.
Care should be taken when commenting out multi-line text:
the comment is effective until the end of the entire block.
.Pp
Argument names not beginning with a letter, digit, or underscore
must be quoted.
.Pp
Additional configuration files can be included with the
.Ic include
keyword, for example:
.Bd -literal -offset indent
include "/etc/httpd.conf.local"
.Ed
.Sh MACROS
Macros can be defined that will later be expanded in context.
Macro names must start with a letter, digit, or underscore,
and may contain any of those characters.
Macro names may not be reserved words (for example,
.Ic table ,
.Ic relay ,
or
.Ic timeout ) .
Macros are not expanded inside quotes.
.Pp
For example:
.Bd -literal -offset indent
ext_ip="10.0.0.1"
server "default" {
	listen on $ext_ip port 80
}
.Ed
.Sh GLOBAL CONFIGURATION
Here are the settings that can be set globally:
.Bl -tag -width Ds
.It Ic prefork Ar number
Run the specified number of server processes.
This increases the performance and prevents delays when connecting
to a server.
.Xr httpd 8
runs 3 server processes by default.
.It Ic chroot Ar directory
Set the
.Xr chroot 2
directory.
If not specified, it defaults to
.Pa /var/www ,
the home directory of the www user.
.El
.Sh SERVERS
The configured web servers.
.Pp
Each
.Ic server
must have a
.Ar name
and include one or more lines of the following syntax:
.Bl -tag -width Ds
.It Ic connection Ar option
Set the specified options and limits for HTTP connections.
Valid options are:
.Bl -tag -width Ds
.It Ic max requests Ar number
Set the maximum number of requests per persistent HTTP connection.
Persistent connections are negotiated using the Keep-Alive header in
HTTP/1.0 and enabled by default in HTTP/1.1.
The default maximum number of requests per connection is
.Ar 100 .
.It Ic timeout Ar seconds
Specify the inactivity timeout in seconds for accepted sessions.
The default timeout is 600 seconds (10 minutes).
The maximum is 2147483647 seconds (68 years).
.El
.It Ic directory Ar option
Set the specified options when serving or accessing directories.
Valid options are:
.Bl -tag -width Ds
.It Oo Ic no Oc Ic auto index
If no index file is found, automatically generate a directory listing.
This is disabled by default.
.It Ic index Ar string
Set the directory index file.
If not specified, it defaults to
.Pa index.html .
.It Ic no index
Disable the directory index.
.Nm httpd
will neither display nor generate a directory index.
.El
.It Oo Ic no Oc Ic fastcgi Op Ic socket Ar socket
Enable FastCGI instead of serving files.
The
.Ar socket
is a local path name within the
.Xr chroot 2
root directory of
.Nm httpd
and defaults to
.Pa /run/slowcgi.sock .
.It Ic listen on Ar address Ic port Ar number Op Ic ssl
Set the listen address and port.
.It Ic location Ar path { ... }
Specify server configuration rules for a specific location.
The
.Ar path
argument will be matched against the URL path with shell globbing rules.
A location section may include most of the server configuration rules
except
.Ic connection ,
.Ic listen on ,
.Ic location
and
.Ic tcp .
.It Oo Ic no Oc Ic log Op Ar option
Set the specified logging options.
Logging is enabled by default using the standard
.Ic access
and
.Ic error
log files,
but can be changed per server or location.
Use the
.Ic no log
directive to disable logging of any requests.
Valid options are:
.Bl -tag -width Ds
.It Ic access Ar name
Set the
.Ar name
of the access log file relative to the log directory.
If not specified, it defaults to
.Pa access.log .
.It Ic error Ar name
Set the
.Ar name
of the error log file relative to the log directory.
If not specified, it defaults to
.Pa error.log .
.It Ic style Ar style
Set the logging style.
The
.Ar style
can be
.Ar common ,
.Ar combined
or
.Ar connection .
The styles
.Ar common
and
.Ar combined
write a log entry after each request similar to the standard Apache
and nginx access log formats.
The style
.Ar connection
writes a summarized log entry after each connection,
that can have multiple requests,
similar to the format that is used by
.Xr relayd 8 .
If not specified, the default is
.Ar common .
.It Oo Ic no Oc Ic syslog
Enable or disable logging to syslog instead of the log files.
.El
.It Ic root Ar directory
Set the document root of the server.
The
.Ar directory
is a pathname within the
.Xr chroot 2
root directory of
.Nm httpd .
If not specified, it defaults to
.Pa /htdocs .
.It Ic tcp Ar option
Enable or disable the specified TCP/IP options; see
.Xr tcp 4
and
.Xr ip 4
for more information about the options.
Valid options are:
.Bl -tag -width Ds
.It Ic backlog Ar number
Set the maximum length the queue of pending connections may grow to.
The backlog option is 10 by default and is limited by the
.Ic kern.somaxconn
.Xr sysctl 8
variable.
.It Ic ip minttl Ar number
This option for the underlying IP connection may be used to discard packets
with a TTL lower than the specified value.
This can be used to implement the
.Ar Generalized TTL Security Mechanism (GTSM)
according to RFC 5082.
.It Ic ip ttl Ar number
Change the default time-to-live value in the IP headers.
.It Xo
.Op Ic no
.Ic nodelay
.Xc
Enable the TCP NODELAY option for this connection.
This is recommended to avoid delays in the relayed data stream,
e.g. for SSH connections.
.It Xo
.Op Ic no
.Ic sack
.Xc
Use selective acknowledgements for this connection.
.It Ic socket buffer Ar number
Set the socket-level buffer size for input and output for this
connection.
This will affect the TCP window size.
.El
.El
.Sh TYPES
Configure the supported media types.
.Nm httpd
will set the
.Ar Content-Type
of the response header based on the file extension listed in the
.Ic types
section.
If not specified,
.Nm httpd
will use built-in media types for
.Ar text/css ,
.Ar text/html ,
.Ar text/plain ,
.Ar image/gif ,
.Ar image/png ,
.Ar image/jpeg ,
and
.Ar application/javascript .
.Pp
The
.Ic types
section must include one or more lines of the following syntax:
.Bl -tag -width Ds
.It Ar type/subtype Ar name Op Ar name ... ;
Set the media
.Ar type
and
.Ar subtype
to the specified extension
.Ar name .
One or more names can be specified per line.
.El
.Sh EXAMPLES
The following example will start one server that is pre-forked two
times and listening on the primary IP address of the network interface
that is a member of the
.Ar egress
group.
It additionally defines some media types overriding the defaults.
.Bd -literal -offset indent
prefork 2

server "default" {
	listen on egress port 80
}

types {
	text/css			css;
	text/html			htm html;
	text/txt			txt;
	image/gif			gif;
	image/jpeg			jpg jpeg;
	image/png			png;
	application/javascript		js;
	application/xml			xml;
}
.Ed
.Pp
Multiple servers can be configured to support hosting of different domains.
If the same address is repeated multiple times in the
.Ic listen on
statement,
the server will be matched based on the requested host name.
.Bd -literal -offset indent
server "www.a.example.com" {
	listen on 203.0.113.1 port 80
	root "/htdocs/www.a.example.com"
}

server "www.b.example.com" {
	listen on 203.0.113.1 port 80
	root "/htdocs/www.b.example.com"
}

server "intranet.example.com" {
	listen on 10.0.0.1 port 80
	root "/htdocs/intranet.example.com"
}
.Ed
.Pp
The syntax of the types section is compatible with the format used by
.Xr nginx 8 ,
so it is possible to include its
.Pa mime.types
file directly:
.Bd -literal -offset indent
include "/etc/nginx/mime.types"
.Ed
.Sh SEE ALSO
.Xr httpd 8
.Sh AUTHORS
.An -nosplit
The
.Xr httpd 8
program was written by
.An Reyk Floeter Aq Mt reyk@openbsd.org .