xref: /openbsd-src/usr.sbin/httpd/httpd.conf.5 (revision 1939637b53ef54ee1e1333e405805d42d8fe096d)
1.\"	$OpenBSD: httpd.conf.5,v 1.125 2023/11/03 13:03:02 espie Exp $
2.\"
3.\" Copyright (c) 2014, 2015 Reyk Floeter <reyk@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: November 3 2023 $
18.Dt HTTPD.CONF 5
19.Os
20.Sh NAME
21.Nm httpd.conf
22.Nd HTTP daemon configuration file
23.Sh DESCRIPTION
24.Nm
25is the configuration file for the HTTP daemon,
26.Xr httpd 8 .
27.Pp
28.Nm
29is divided into the following main sections:
30.Bl -tag -width xxxx
31.It Sy Macros
32User-defined variables may be defined and used later, simplifying the
33configuration file.
34.It Sy Global Configuration
35Global settings for
36.Xr httpd 8 .
37.It Sy Servers
38Listening HTTP web servers.
39.It Sy Types
40Media types and extensions.
41.El
42.Pp
43Within the sections,
44a host
45.Ar address
46can be specified by IPv4 address, IPv6 address, interface name,
47interface group, or DNS hostname.
48If the address is an interface name,
49.Xr httpd 8
50will look up the first IPv4 address and any other IPv4 and IPv6
51addresses of the specified network interface.
52If
53.Sq *
54is given as an address,
55.Xr httpd 8
56will listen on all IPv4 and IPv6 addresses.
57.Ar 0.0.0.0
58means to listen on all IPv4 addresses and
59.Ar ::
60all IPv6 addresses.
61A
62.Ar port
63can be specified by number or name.
64The port name to number mappings are found in the file
65.Pa /etc/services ;
66see
67.Xr services 5
68for details.
69.Pp
70The current line can be extended over multiple lines using a backslash
71.Pq Sq \e .
72Comments can be put anywhere in the file using a hash mark
73.Pq Sq # ,
74and extend to the end of the current line.
75Care should be taken when commenting out multi-line text:
76the comment is effective until the end of the entire block.
77.Pp
78Argument names not beginning with a letter, digit, or underscore
79must be quoted.
80.Pp
81Additional configuration files can be included with the
82.Ic include
83keyword, for example:
84.Bd -literal -offset indent
85include "/etc/httpd.conf.local"
86.Ed
87.Sh MACROS
88Macros can be defined that will later be expanded in context.
89Macro names must start with a letter, digit, or underscore,
90and may contain any of those characters.
91Macro names may not be reserved words (for example,
92.Ic directory ,
93.Ic log ,
94or
95.Ic root ) .
96Macros are not expanded inside quotes.
97.Pp
98For example:
99.Bd -literal -offset indent
100ext_ip="10.0.0.1"
101server "example.com" {
102	listen on $ext_ip port 80
103}
104.Ed
105.Sh GLOBAL CONFIGURATION
106Here are the settings that can be set globally:
107.Bl -tag -width Ds
108.It Ic chroot Ar directory
109Set the
110.Xr chroot 2
111directory.
112If not specified, it defaults to
113.Pa /var/www ,
114the home directory of the www user.
115.It Ic default type Ar type/subtype
116Set the default media type that is used if the media type for a
117specified extension is not found in the configured types or for files
118without a file extension;
119see the
120.Sx TYPES
121section below.
122If not specified, the default type is set to
123.Ar application/octet-stream .
124.It Ic errdocs Ar directory
125Let
126.Xr httpd 8
127return custom error documents instead of the built-in ones.
128.Pp
129.Ar directory
130is relative to the
131.Ic chroot .
132.Pp
133Custom error documents are standalone
134.Dq .html
135files provided in one of the following ways:
136.Bl -bullet -offset indent -compact
137.It
138As HTML files named after the 3-digit HTTP response code they are used
139for, e.g.,
140.Pa 404.html .
141.It
142As a generic template file named
143.Pa err.html
144which is used for response codes no dedicated file is provided for.
145.El
146.Pp
147In case the latter does not exist and there is no dedicated file available for
148a certain response code, the built-in error document will be used as fallback.
149.Pp
150A custom error document may contain the following macros that will be expanded
151at runtime:
152.Pp
153.Bl -tag -width $RESPONSE_CODE -offset indent -compact
154.It Ic $HTTP_ERROR
155The error message text.
156.It Ic $RESPONSE_CODE
157The 3-digit HTTP response code sent to the client.
158.It Ic $SERVER_SOFTWARE
159The server software name of
160.Xr httpd 8 .
161.El
162.It Ic logdir Ar directory
163Specifies the full path of the directory in which log files will be written.
164If not specified, it defaults to
165.Pa /logs
166within the
167.Xr chroot 2
168directory.
169.It Ic prefork Ar number
170Run the specified number of server processes.
171This increases the performance and prevents delays when connecting
172to a server.
173.Xr httpd 8
174runs 3 server processes by default.
175.El
176.Sh SERVERS
177The configured web servers.
178.Pp
179Each
180.Ic server
181section starts with a declaration of the server
182.Ar name .
183If a request does not match any server name, it is handled by the
184first defined
185.Ic server
186section that matches the listening port.
187.Bl -tag -width Ds
188.It Ic server Ar name Brq ...
189Match the server name using shell globbing rules,
190see
191.Xr glob 7 .
192This can be an explicit name,
193.Ar www.example.com ,
194or a name including wildcards,
195.Ar *.example.com .
196.It Ic server match Ar name Brq ...
197Match the server name using pattern matching,
198see
199.Xr patterns 7 .
200.El
201.Pp
202Followed by a block of options enclosed in curly braces:
203.Bl -tag -width Ds
204.It Ic alias Ar name
205Specify an additional alias
206.Ar name
207for this server.
208.It Ic alias match Ar name
209Like the
210.Ic alias
211option,
212but
213.Ic match
214the
215.Ar name
216using pattern matching instead of shell globbing rules,
217see
218.Xr patterns 7 .
219.It Oo Ic no Oc Ic authenticate Oo Ar realm Oc Ic with Pa htpasswd
220Authenticate a remote user for
221.Ar realm
222by checking the credentials against the user authentication file
223.Pa htpasswd .
224The file name is relative to the
225.Ic chroot
226and must be readable by the www user.
227Use the
228.Ic no authenticate
229directive to disable authentication in a location.
230.It Ic block drop
231Drop the connection without sending an error page.
232.It Ic block Op Ic return Ar code Op Ar uri
233Close the connection and send an error page.
234If the optional return code is not specified,
235.Xr httpd 8
236denies access with a
237.Sq 403 Forbidden
238response.
239The optional
240.Ar uri
241argument can be used with return codes in the 3xx range to send an
242HTTP Location header for redirection to a specified URI.
243.Pp
244It is possible to rewrite the request to redirect it to a different
245external location.
246The
247.Ar uri
248may contain predefined macros that will be expanded at runtime:
249.Pp
250.Bl -tag -width $DOCUMENT_URI -offset indent -compact
251.It Ic $DOCUMENT_URI
252The request path.
253.It Ic $QUERY_STRING
254The query string of the request.
255.It Ic $QUERY_STRING_ENC
256The URL-encoded query string of the request.
257.It Ic $REMOTE_ADDR
258The IP address of the connected client.
259.It Ic $REMOTE_PORT
260The TCP source port of the connected client.
261.It Ic $REMOTE_USER
262The remote user for HTTP authentication.
263.It Ic $REQUEST_SCHEME
264The request scheme (http or https).
265.It Ic $REQUEST_URI
266The request path and optional query string.
267.It Ic $SERVER_ADDR
268The configured IP address of the server.
269.It Ic $SERVER_PORT
270The configured TCP port of the server.
271.It Ic $SERVER_NAME
272The name of the server.
273.It Ic $HTTP_HOST
274The host from the HTTP Host header.
275.It Pf % Ar n
276The capture index
277.Ar n
278of a string that was captured by the enclosing
279.Ic location match
280option.
281.El
282.It Ic connection Ar option
283Set the specified options and limits for HTTP connections.
284Multiple options may be specified within curly braces.
285Valid options are:
286.Bl -tag -width Ds
287.It Ic max request body Ar number
288Set the maximum body size in bytes that the client can send to the server.
289The default value is 1048576 bytes (1M).
290.It Ic max requests Ar number
291Set the maximum number of requests per persistent HTTP connection.
292Persistent connections are negotiated using the Keep-Alive header in
293HTTP/1.0 and enabled by default in HTTP/1.1.
294The default maximum number of requests per connection is 100.
295.It Ic request timeout Ar seconds
296Specify the inactivity timeout for HTTP operations between client and server,
297for example the maximum time to wait for a request from the client.
298The default timeout is 60 seconds (1 minute).
299The maximum is 2147483647 seconds (68 years).
300.It Ic timeout Ar seconds
301Specify the inactivity timeout in seconds for accepted sessions,
302for example the maximum time to wait for I/O from the FastCGI backend.
303The default timeout is 600 seconds (10 minutes).
304The maximum is 2147483647 seconds (68 years).
305.El
306.It Ic default type Ar type/subtype
307Set the default media type for the specified location,
308overwriting the global setting.
309.It Ic directory Ar option
310Set the specified options when serving or accessing directories.
311Multiple options may be specified within curly braces.
312Valid options are:
313.Bl -tag -width Ds
314.It Oo Ic no Oc Ic auto index
315If no index file is found, automatically generate a directory listing.
316This is disabled by default.
317.It Ic index Ar string
318Set the directory index file.
319If not specified, it defaults to
320.Pa index.html .
321.It Ic no index
322Disable the directory index.
323.Xr httpd 8
324will neither display nor generate a directory index.
325.El
326.It Oo Ic no Oc Ic errdocs Ar directory
327Overrides or, if the
328.Ic no
329keyword is given, disables globally defined custom error documents for the
330current
331.Ic server .
332.It Oo Ic no Oc Ic fastcgi Oo Ar option Oc
333Enable FastCGI instead of serving files.
334Multiple options may be specified within curly braces.
335Valid options are:
336.Bl -tag -width Ds
337.It Ic socket Oo Cm tcp Oc Ar socket Oo Ar port Oc
338.Nm httpd
339passes HTTP requests to a FastCGI handler listening on the socket
340.Ar socket .
341The
342.Ar socket
343can either be a UNIX domain socket or a TCP socket.
344If the FastCGI handler is listening on a UNIX domain socket,
345.Ar socket
346is a local path name within the
347.Xr chroot 2
348root directory of
349.Xr httpd 8
350and defaults to
351.Pa /run/slowcgi.sock .
352Alternatively if
353the FastCGI handler is listening on a TCP socket,
354.Ar socket
355is a hostname or an IP address.
356If the
357.Ar port
358is not specified, it defaults to port 9000.
359.It Ic strip Ar number
360Strip
361.Ar number
362path components from the beginning of DOCUMENT_ROOT and
363SCRIPT_FILENAME before sending them to the FastCGI server.
364This allows FastCGI server chroot to be a directory under httpd chroot.
365.It Ic param Ar variable value
366Sets a variable that will be sent to the FastCGI server.
367Each statement defines one variable.
368.El
369.Pp
370The FastCGI handler will be given the following variables by default:
371.Pp
372.Bl -tag -width GATEWAY_INTERFACE -offset indent -compact
373.It Ic DOCUMENT_ROOT
374The document root in which the script is located as configured by the
375.Ic root
376option for the server or location that matches the request.
377.It Ic GATEWAY_INTERFACE
378The revision of the CGI specification used.
379.It Ic HTTP_*
380Additional HTTP headers the connected client sent in the request, if
381any.
382.It Ic HTTPS
383A variable that is set to
384.Qq on
385when the server has been configured to use TLS.
386This variable is omitted otherwise.
387.It Ic REQUEST_URI
388The path and optional query string as requested by the connected client.
389.It Ic DOCUMENT_URI
390The canonicalized request path, possibly with a slash or
391directory index file name appended.
392This is the same as
393.Ic PATH_INFO
394appended to
395.Ic SCRIPT_NAME .
396.It Ic SCRIPT_NAME
397The virtual URI path to the script.
398.It Ic PATH_INFO
399The optional path appended after the script name in the request path.
400This variable is an empty string if no path is appended after the
401script name.
402.It Ic SCRIPT_FILENAME
403The absolute, physical path to the script within the
404.Xr chroot 2
405directory.
406.It Ic QUERY_STRING
407The optional query string of the request.
408This variable is an empty
409string if there is no query string in the request.
410.It Ic REMOTE_ADDR
411The IP address of the connected client.
412.It Ic REMOTE_PORT
413The TCP source port of the connected client.
414.It Ic REMOTE_USER
415The remote user when using HTTP authentication.
416.It Ic REQUEST_METHOD
417The HTTP method the connected client used when making the request.
418.It Ic SERVER_ADDR
419The configured IP address of the server.
420.It Ic SERVER_NAME
421The name of the server.
422.It Ic SERVER_PORT
423The configured TCP server port of the server.
424.It Ic SERVER_PROTOCOL
425The revision of the HTTP specification used.
426.It Ic SERVER_SOFTWARE
427The server software name of
428.Xr httpd 8 .
429.It Ic TLS_PEER_VERIFY
430A variable that is set to a comma separated list of TLS client verification
431features in use
432.Pq omitted when TLS client verification is not in use .
433.El
434.It Ic gzip-static
435Enable static gzip compression to save bandwidth.
436.Pp
437If gzip encoding is accepted and if the requested file exists with
438an additional .gz suffix, use the compressed file instead and deliver
439it with content encoding gzip.
440.It Ic hsts Oo Ar option Oc
441Enable HTTP Strict Transport Security.
442Valid options are:
443.Bl -tag -width Ds
444.It Ic max-age Ar seconds
445Set the maximum time in seconds a receiving user agent should regard
446this host as an HSTS host.
447The default is one year.
448.It Ic preload
449Confirm and authenticate that the site is permitted to be included in
450a browser's preload list.
451.It Ic subdomains
452Signal to the receiving user agent that this host and all sub domains
453of the host's domain should be considered HSTS hosts.
454.El
455.It Ic listen on Ar address Oo Ic tls Oc Ic port Ar number
456Set the listen address and port.
457This statement can be specified multiple times.
458.It Ic location Oo Oo Ic not Oc Ic found Oc Ar path Brq ...
459Specify server configuration rules for a specific location.
460The
461.Ar path
462argument will be matched against the request path with shell globbing rules.
463Optionally, it is also possible to match for
464.Ic found
465(i.e. accessible) or
466.Ic not found
467request paths only.
468In case of multiple location statements in the same context, the
469first matching location statement will be put into effect, while all
470later ones will be ignored.
471Therefore it is advisable to match for more specific paths first
472and for generic ones later on.
473A location section may include most of the server configuration rules
474except
475.Ic alias ,
476.Ic connection ,
477.Ic errdocs ,
478.Ic hsts ,
479.Ic listen on ,
480.Ic location ,
481.Ic tcp
482and
483.Ic tls .
484.It Ic location Oo Oo Ic not Oc Ic found Oc Ic match Ar path Brq ...
485Like the
486.Ic location
487option,
488but
489.Ic match
490the
491.Ar path
492using pattern matching instead of shell globbing rules,
493see
494.Xr patterns 7 .
495The pattern may contain captures that can be used in an enclosed
496.Ic block return
497or
498.Ic request rewrite
499option.
500.It Oo Ic no Oc Ic log Op Ar option
501Set the specified logging options.
502Logging is enabled by default using the standard
503.Ic access
504and
505.Ic error
506log files,
507but can be changed per server or location.
508Use the
509.Ic no log
510directive to disable logging of any requests.
511Multiple options may be specified within curly braces.
512Valid options are:
513.Bl -tag -width Ds
514.It Ic access Ar name
515Set the
516.Ar name
517of the access log file relative to the log directory.
518If not specified, it defaults to
519.Pa access.log .
520.It Ic error Ar name
521Set the
522.Ar name
523of the error log file relative to the log directory.
524If not specified, it defaults to
525.Pa error.log .
526.It Ic style Ar style
527Set the logging style.
528The
529.Ar style
530can be
531.Cm common ,
532.Cm combined ,
533.Cm forwarded
534or
535.Cm connection .
536The styles
537.Cm common
538and
539.Cm combined
540write a log entry after each request similar to the standard Apache
541and nginx access log formats.
542The style
543.Cm forwarded
544extends the style
545.Cm combined
546by appending two fields containing the values of the headers
547.Ar X-Forwarded-For
548and
549.Ar X-Forwarded-Port .
550The style
551.Cm connection
552writes a summarized log entry after each connection,
553that can have multiple requests,
554similar to the format that is used by
555.Xr relayd 8 .
556If not specified, the default is
557.Cm common .
558.It Oo Ic no Oc Ic syslog
559Enable or disable logging to
560.Xr syslog 3
561instead of the log files.
562.El
563.It Ic pass
564Disable any previous
565.Ic block
566in a location.
567.It Ic request Ar option
568Configure the options for the request path.
569Multiple options may be specified within curly braces.
570Valid options are:
571.Bl -tag -width Ds
572.It Oo Ic no Oc Ic rewrite Ar path
573Enable or disable rewriting of the request.
574Unlike the redirection with
575.Ic block return ,
576this will change the request path internally before
577.Nm httpd
578makes a final decision about the matching location.
579The
580.Ar path
581argument may contain predefined macros that will be expanded at runtime.
582See the
583.Ic block return
584option for the list of supported macros.
585.It Ic strip Ar number
586Strip
587.Ar number
588path components from the beginning of the request path before looking
589up the stripped-down path at the document root.
590.El
591.It Ic root Ar directory
592Configure the document root of the server.
593The
594.Ar directory
595is a pathname within the
596.Xr chroot 2
597root directory of
598.Nm httpd .
599If not specified, it defaults to
600.Pa /htdocs .
601.It Ic tcp Ar option
602Enable or disable the specified TCP/IP options; see
603.Xr tcp 4
604and
605.Xr ip 4
606for more information about the options.
607Multiple options may be specified within curly braces.
608Valid options are:
609.Bl -tag -width Ds
610.It Ic backlog Ar number
611Set the maximum length the queue of pending connections may grow to.
612The backlog option is 10 by default and is limited by the
613.Va kern.somaxconn
614.Xr sysctl 8
615variable.
616.It Ic ip minttl Ar number
617This option for the underlying IP connection may be used to discard packets
618with a TTL lower than the specified value.
619This can be used to implement the
620Generalized TTL Security Mechanism (GTSM)
621according to RFC 5082.
622.It Ic ip ttl Ar number
623Change the default time-to-live value in the IP headers.
624.It Oo Ic no Oc Ic nodelay
625Enable the TCP NODELAY option for this connection.
626This is recommended to avoid delays in the data stream.
627.It Oo Ic no Oc Ic sack
628Use selective acknowledgements for this connection.
629.It Ic socket buffer Ar number
630Set the socket-level buffer size for input and output for this
631connection.
632This will affect the TCP window size.
633.El
634.It Ic tls Ar option
635Set the TLS configuration for the server.
636These options are only used if TLS has been enabled via the listen directive.
637Multiple options may be specified within curly braces.
638Valid options are:
639.Bl -tag -width Ds
640.It Ic certificate Ar file
641Specify the certificate to use for this server.
642The
643.Ar file
644should contain a PEM encoded certificate.
645The default is
646.Pa /etc/ssl/server.crt .
647.It Ic ciphers Ar string
648Specify the TLS cipher string.
649If not specified, the default value
650.Qq HIGH:!aNULL
651will be used (strong crypto cipher suites without anonymous DH).
652See the CIPHERS section of
653.Xr openssl 1
654for information about TLS cipher suites and preference lists.
655.It Ic client ca Ar cafile Oo Ic crl Ar crlfile Oc Op Ic optional
656Require
657.Po
658or, if
659.Ic optional
660is specified, request but do not require
661.Pc
662TLS client certificates whose authenticity can be verified
663against the CA certificate(s) in
664.Ar cafile
665in order to proceed beyond the TLS handshake.
666With
667.Ic crl
668specified, additionally require that no certificate in the client chain be
669listed as revoked in the CRL(s) in
670.Ar crlfile .
671CA certificates and CRLs should be PEM encoded.
672.It Ic dhe Ar params
673Specify the DHE parameters to use for DHE cipher suites.
674Valid parameter values are none, legacy and auto.
675For legacy a fixed key length of 1024 bits is used, whereas for auto the key
676length is determined automatically.
677The default is none, which disables DHE cipher suites.
678.It Ic ecdhe Ar curves
679Specify a comma separated list of elliptic curves to use for ECDHE cipher suites,
680in order of preference.
681The special value of "default" will use the default curves; see
682.Xr tls_config_set_ecdhecurves 3
683for further details.
684.It Ic key Ar file
685Specify the private key to use for this server.
686The
687.Ar file
688should contain a PEM encoded private key and reside outside of the
689.Xr chroot 2
690root directory of
691.Nm httpd .
692The default is
693.Pa /etc/ssl/private/server.key .
694.It Ic ocsp Ar file
695Specify an OCSP response to be stapled during TLS handshakes
696with this server.
697The
698.Ar file
699should contain a DER-format OCSP response retrieved from an
700OCSP server for the
701.Ar certificate
702in use,
703and can be created using
704.Xr ocspcheck 8 .
705The path to
706.Ar file
707is not relative to the chroot.
708If the OCSP response in
709.Ar file
710is empty, OCSP stapling will not be used.
711The default is to not use OCSP stapling.
712.It Ic protocols Ar string
713Specify the TLS protocols to enable for this server.
714Refer to the
715.Xr tls_config_parse_protocols 3
716function for valid protocol string values.
717By default, TLSv1.3 and TLSv1.2 will be used.
718.It Ic ticket lifetime Ar seconds
719Enable TLS session tickets with a
720.Ar seconds
721session lifetime.
722It is possible to set
723.Ar seconds
724to default to use the httpd default timeout of 2 hours.
725.El
726.El
727.Sh TYPES
728Configure the supported media types.
729.Xr httpd 8
730will set the
731.Ar Content-Type
732of the response header based on the file extension listed in the
733.Ic types
734section.
735If not specified,
736.Xr httpd 8
737will use built-in media types for
738.Ar text/css ,
739.Ar text/html ,
740.Ar text/plain ,
741.Ar image/gif ,
742.Ar image/png ,
743.Ar image/jpeg ,
744.Ar image/svg+xml ,
745and
746.Ar application/javascript .
747.Pp
748The
749.Ic types
750section must include one or more lines of the following syntax,
751enclosed in curly braces:
752.Bl -tag -width Ds
753.It Ar type/subtype Ar name Op Ar name ...
754Set the media
755.Ar type
756and
757.Ar subtype
758to the specified extension
759.Ar name .
760One or more names can be specified per line.
761Each line may end with an optional semicolon.
762Later lines overwrite earlier lines.
763.It Ic include Ar file
764Include types definitions from an external file, for example
765.Pa /usr/share/misc/mime.types .
766.El
767.Sh FILES
768.Bl -tag -width /etc/examples/httpd.conf -compact
769.It Pa /etc/examples/httpd.conf
770Example configuration file.
771.El
772.Sh EXAMPLES
773Example configuration files for
774.Nm
775and
776.Xr acme-client 1
777are provided in
778.Pa /etc/examples/httpd.conf
779and
780.Pa /etc/examples/acme-client.conf .
781.Pp
782The following example will start one server that is pre-forked two
783times and is listening on all local IP addresses.
784It additionally defines some media types overriding the defaults.
785.Bd -literal -offset indent
786prefork 2
787
788server "example.com" {
789	listen on * port 80
790}
791
792types {
793	text/css		css
794	text/html		html htm
795	text/plain		txt
796	image/gif		gif
797	image/jpeg		jpeg jpg
798	image/png		png
799	application/javascript	js
800	application/xml		xml
801}
802.Ed
803.Pp
804The server can also be configured to only listen on the primary IP
805address of the network interface that is a member of the
806.Qq egress
807group.
808.Bd -literal -offset indent
809server "example.com" {
810	listen on egress port 80
811}
812.Ed
813.Pp
814Multiple servers can be configured to support hosting of different domains.
815If the same address is repeated multiple times in the
816.Ic listen on
817statement,
818the server will be matched based on the requested host name.
819.Bd -literal -offset indent
820server "www.example.com" {
821	alias "example.com"
822	listen on * port 80
823	listen on * tls port 443
824	root "/htdocs/www.example.com"
825}
826
827server "www.a.example.com" {
828	listen on 203.0.113.1 port 80
829	root "/htdocs/www.a.example.com"
830}
831
832server "www.b.example.com" {
833	listen on 203.0.113.1 port 80
834	root "/htdocs/www.b.example.com"
835}
836
837server "intranet.example.com" {
838	listen on 10.0.0.1 port 80
839	root "/htdocs/intranet.example.com"
840}
841.Ed
842.Pp
843Simple redirections can be configured with the
844.Ic block
845directive:
846.Bd -literal -offset indent
847server "example.com" {
848	listen on 10.0.0.1 port 80
849	listen on 10.0.0.1 tls port 443
850	block return 301 "$REQUEST_SCHEME://www.example.com$REQUEST_URI"
851}
852
853server "www.example.com" {
854	listen on 10.0.0.1 port 80
855	listen on 10.0.0.1 tls port 443
856}
857.Ed
858.Pp
859The request can also be rewritten with the
860.Ic request rewrite
861directive:
862.Bd -literal -offset indent
863server "example.com" {
864	listen on * port 80
865	location match "/old/(.*)" {
866		request rewrite "/new/%1"
867	}
868}
869.Ed
870.Sh SEE ALSO
871.Xr htpasswd 1 ,
872.Xr glob 7 ,
873.Xr patterns 7 ,
874.Xr httpd 8 ,
875.Xr ocspcheck 8 ,
876.Xr slowcgi 8
877.Sh AUTHORS
878.An -nosplit
879The
880.Xr httpd 8
881program was written by
882.An Reyk Floeter Aq Mt reyk@openbsd.org .
883