1YAWS.CONF(5)                     User Commands                    YAWS.CONF(5)
2
3
4

NAME

6       /etc/yaws/yaws.conf - Configuration file for the Yaws web server
7

DESCRIPTION

9       Yaws  is  fast  lightweight  web  server. It reads a configuration file
10       called yaws.conf to control its operations. The configuration  contains
11       two  distinct  parts: a global part which affects all the virtual hosts
12       and a server part where options for each virtual host is supplied.
13
14

GLOBAL PART

16       logdir = [+]Directory
17              All Yaws logs will be written to files  in  this  directory.  If
18              specified  with  +, Yaws will attempt to create the directory if
19              it does not exist. There are several different log files written
20              by Yaws:
21
22              report.log  - this is a text file that contains all error logger
23              printouts from Yaws.
24
25              <Host>.access - for each virtual host served  by  Yaws,  a  file
26              <Host>.access  will  be  written  that contains an access log in
27              NCSA combined/XLF/ELF log format. (See  http://www.w3.org/TR/WD-
28              logfile.html for more details on Extended Log File Format.)
29
30              <Host>.auth  -  for  each  virtual  host  served by Yaws, a file
31              <Host>.auth will be written which contains all http auth related
32              messages.
33
34              trace_<YYYYMMDD_hhmmss> - Trace files are written in this subdi‐
35              rectory, suffixed by the creation date.
36
37                   trace.<Pid>.http - this file contains  the  HTTP  trace  if
38                   that is enabled, where <Pid> is the process id handling the
39                   TCP connection.
40
41                   trace.<Pid>.traffic - this file contains the traffic  trace
42                   if  that is enabled, where <Pid> is the process id handling
43                   the TCP connection.
44
45
46              Note that <Host>.access and <Host>.auth files will be used  only
47              if  the  directive logger_mod is not set or set to yaws_log. The
48              default value for logdir is "."
49
50
51       ebin_dir = Directory
52              This directive adds Directory to the Erlang search path.  It  is
53              possible  to have several of these commands in the configuration
54              file. The default value is "yaws_dir"/examples/ebin
55
56
57       src_dir = Directory
58              This directive defines a Directory as a source  directory.  Yaws
59              will  compile all erlang modules found in this directory and all
60              its subdirectories. The compilation occurs when  the  configura‐
61              tion  is loaded or reloaded. The include_dir directives are used
62              to search for includes files. Multiple src_dir directives may be
63              used. There is no such directory configured by default.
64
65
66
67       id = String
68              It is possible to run multiple Yaws servers on the same machine.
69              We use the id of a Yaws server to control it using the different
70              control commands such as:
71
72                # /usr/local/bin/yaws --id foobar --stop
73
74              To  stop the Yaws server with id "foobar". Each Yaws server will
75              write its internal data into a file  called  $HOME/.yaws/yaws/ID
76              where ID is the identity of the server. Yaws also creates a file
77              called $HOME/.yaws/yaws/ID/CTL which contains  the  port  number
78              where  the server is listening for control commands. The default
79              id is "default".
80
81
82       server_signature = String
83              This directive sets the "Server: " output header to  the  custom
84              value.  The  default  value  is  "yaws/%VSN%,  Yet  Another  Web
85              Server".
86
87
88       include_dir = Directory
89              This directive adds Directory to the path of  directories  where
90              the  Erlang  compiler searches for include files. We need to use
91              this if we want to include .hrl files in our Yaws  Erlang  code.
92              It is possible to have several of these commands in the configu‐
93              ration file. The default value is "yaws_dir"/examples/include.
94
95
96       max_num_cached_files = Integer
97              Yaws will cache small files such as commonly accessed GIF images
98              in  RAM.   This directive sets a maximum number on the number of
99              cached files.  The default value is 400.
100
101
102       max_num_cached_bytes = Integer
103              This directive controls the total amount of RAM which can  maxi‐
104              mally  be  used  for  cached  RAM  files.  The  default value is
105              1000000, 1 megabyte.
106
107
108       max_size_cached_file = Integer
109              This directive sets a maximum size on the  files  that  are  RAM
110              cached by Yaws.  The default value is 8000, 8 kBytes.
111
112
113       cache_refresh_secs = Integer
114              The  RAM  cache is used to serve pages that sit in the cache. An
115              entry sits in cache at most cache_refresh_secs  number  of  sec‐
116              onds.  The  default  is  30. This means that when the content is
117              updated under the docroot, that change  doesn't  show  until  30
118              seconds  have  passed.  While  developing a Yaws site, it may be
119              convenient to set this value to 0. If the  debug  flag  (-d)  is
120              passed to the Yaws start script, this value is automatically set
121              to 0.
122
123
124       trace  = false | traffic | http
125              This enables traffic or http tracing. Tracing is  also  possible
126              to enable with a command line flag to Yaws. Default is false.
127
128
129       auth_log  = true | false
130              Deprecated  and  ignored. Now, this target must be set in server
131              part.
132
133
134       max_connections = nolimit | Integer
135              Set this value to control the maximum number of connections from
136              HTTP clients into the server. This is implemented by closing the
137              last socket if the limit threshold is reached.
138
139
140       keepalive_maxuses = nolimit | Integer
141              Normally, Yaws does not restrict the number of times  a  connec‐
142              tion is kept alive using keepalive. Setting this parameter to an
143              integer X will ensure that connections are closed once they have
144              been  used  X times.  This can be a useful to guard against long
145              running connections collecting too much garbage  in  the  Erlang
146              VM.
147
148
149       process_options = undefined | Proplist
150              Set   process  spawn  options  for  client  acceptor  processes.
151              Options must be specified as a quoted string of either the  atom
152              undefined  or  as  a proplist of valid process options. The sup‐
153              ported   options   are   fullsweep_after,   min_heap_size,   and
154              min_bin_vheap_size,  each  taking  an  associated integer value.
155              Other process options are ignored.  The  proplist  may  also  be
156              empty. See erlang:spawn_opt/4 for details on these options.
157
158
159       large_file_chunk_size = Integer
160              Set  the  chunk size used by Yaws to send large files when send‐
161              file is not supported or disabled. The default value is 10240.
162
163
164       large_file_sendfile = erlang | yaws | disable
165              Set the version of sendfile method to use to  send  large  files
166              (if supported):
167
168              erlang - use file:sendfile/5, if supported.
169
170              yaws - use Yaws sendfile linked-in driver, if supported.
171
172              disable - do not use any sendfile method, but gen_tcp:send/2.
173
174              The default value is yaws.
175
176
177       acceptor_pool_size = Integer
178              Set the size of the pool of cached acceptor processes. The spec‐
179              ified value must be greater than or  equal  to  0.  The  default
180              value  is  8.  Specifying  a value of 0 effectively disables the
181              process pool.
182
183
184       log_wrap_size = Integer
185              The logs written by Yaws are all wrap logs, the default value at
186              the size where they wrap around and the original gets renamed to
187              File.old is 1000000, 1 megabyte. This value can be changed.
188              If we set the value to 0 the logs will never wrap. If we want to
189              use Yaws in combination with a more traditional log wrapper such
190              as logrotate, set the size to 0 and Yaws will  reopen  the  log‐
191              files once they have be renamed/removed.
192
193
194       log_resolve_hostname = true | false
195              By  default  the  client  host  IP is not resolved in the access
196              logs.
197
198
199
200       fail_on_bind_err = true | false
201              Fail completely or not if Yaws fails to  bind  a  listen  socket
202              Default is true.
203
204
205       enable_soap = true | false
206              If  true,  a  soap  server  will  be started at startup of Yaws.
207              Default is false.
208
209
210       soap_srv_mods = ListOfModuleSetting
211              If  enable_soap  is   true,   a   startup   Yaws   will   invoke
212              yaws_soap_srv:setup()  to  setup modules set here. ModuleSetting
213              is either a triad like <Mod, HandlerFunc, WsdlFile> or a quadru‐
214              ple  form like <Mod, HandlerFunc, WsdlFile, Prefix> which speci‐
215              fies  the  prefix.  A  prefix  will  be  used  as  argument   of
216              yaws_soap_lib:initModel()  and  then  be used as a XML namespace
217              prefix.  Note, the WsdlFile here should be an absolute-path file
218              in local file systems.
219
220              For example, we can specify
221
222                soap_srv_mods=<Mod1, Handler, Wsdl1> <Mod2, Handler, Wsdl2, Prefix> ...
223
224
225       php_exe_path = Path
226              this  target is deprecated and useless. use 'php_handler' target
227              in server part instead.
228              The name of (and possibly path to) the php  executable  used  to
229              interpret  php  scripts (if allowed).  Default is php_exe_path =
230              php-cgi.
231
232
233       copy_error_log  = true | false
234              Enable or disable copying of the  error  log.  When  we  run  in
235              embedded mode, there may very well be some other systems process
236              that is responsible for writing the errorlog to a  file  whereas
237              when  we  run  in  normal standalone mode, we typically want the
238              Erlang errorlog written to a report.log file.  Default value  is
239              true.
240
241
242       ysession_mod = Module
243              Allows  to  specify  a  different Yaws session storage mechanism
244              instead of an ETS table. One of the  drawbacks  of  the  default
245              yaws_session_server  implementation  is that server side cookies
246              are lost when the server restarts. Specifying a different module
247              here will pass all write/read operations to this module (it must
248              implement appropriate callbacks).
249
250
251       ysession_idle_timeout = Integer
252              Controls Yaws session idle cleanup. If a server  has  been  idle
253              for  ysession_idle_timeout milliseconds, check all Yaws sessions
254              and  remove  any  that  have  timed  out.  The   default   yses‐
255              sion_idle_timeout value is 2*60*1000 (2 minutes).
256
257
258       ysession_long_timeout = Integer
259              Controls    Yaws   session   periodic   cleanup.   Every   yses‐
260              sion_long_timeout milliseconds,  check  all  Yaws  sessions  and
261              remove  any that have timed out. The default ysession_long_time‐
262              out value is 60*60*1000 (1 hour).
263
264
265       runmod = ModuleName
266              At startup Yaws will invoke  ModuleName:start()  in  a  separate
267              process. It is possible to have several runmods.  This is useful
268              if we want to reuse the Yaws startup shell script  for  our  own
269              application.
270
271
272       pick_first_virthost_on_nomatch = true | false
273              When  Yaws  gets a request, it extracts the Host header from the
274              client request to choose a virtual server  amongst  all  servers
275              with  the  same  IP/Port  pair.   This  configuration  parameter
276              decides whether Yaws should pick the first server (as defined in
277              the  yaws.conf  file)  if no name match or not. If this is false
278              and no Host header is present in the request, Yaws returns a 400
279              Bad Request as required by the HTTP standard. In real live host‐
280              ing scenarios we typically want this to  be  false,  whereas  in
281              testing/development  scenarios it may be convenient to set it to
282              true. Default is true.
283
284
285       keepalive_timeout = TimeInMilliseconds | infinity
286              If the HTTP session will be kept alive  (i.e.,  not  immediately
287              closed)  it  will  close  after  keepalive_timeout  milliseconds
288              unless a new request is received in that time. The default value
289              is 30000. The value infinity is legal but not recommended.
290
291
292       subconfig = File
293              Load  specified  config file. Absolute paths or relative ones to
294              the configuration  location  are  allowed.  Unix-style  wildcard
295              strings  can  be  used  to  include  several  files at once. See
296              filelib:wildcard/1 for details. Hidden files, starting by a dot,
297              will be ignored. For example:
298
299                subconfig = /etc/yaws/global.conf
300                subconfig = /etc/yaws/vhosts/*.conf
301
302              Or, relatively to the configuration location:
303
304                subconfig = global.conf
305                subconfig = vhosts/*.conf
306
307
308       subconfigdir = Directory
309              Load  all  config  files  found  in the specified directory. The
310              given Directory can be an absolute path or relative to the  con‐
311              figuration  location.  Hidden  files, starting by a dot, will be
312              ignored.
313
314
315       x_forwarded_for_log_proxy_whitelist = ListOfUpstreamProxyServerIps
316              this target is deprecated and will be ignored.
317
318
319       default_type = MimeType
320              Defines the default MIME type  to  be  used  where  Yaws  cannot
321              determine it by its MIME types mappings. Default is text/plain.
322
323
324       default_charset = Charset
325              Defines the default charset to be added when a response content-
326              type is text/*. By default, no charset is added.
327
328
329       mime_types_file = File
330              Overrides the default mime.types file included with  Yaws.  This
331              file must use the following format:
332
333                # Lines beginning with a '#' or a whitespace are ignored
334                # blank lines are also ignored
335                <MIME type> <space separated file extensions>
336
337              The      default      file      is     located     at     ${PRE‐
338              FIX}/lib/yaws/priv/mime.types. You should  not  edit  this  file
339              because it may be replaced when you upgrade your server.
340
341
342       add_types = ListOfTypes
343              Specifies  one  or  more  mappings  between  MIME types and file
344              extensions. More than one extension can be assigned  to  a  MIME
345              type. ListOfTypes is defined as follows:
346
347                add_types = <MimeType1, Ext> <MimeType2, Ext1 Ext2 ...> ...
348
349              The  mappings  defined  using  this  directive will overload all
350              other definitions. If a file extension is defined several times,
351              only  the last one is kept. Multiple add_types directives may be
352              used.
353
354
355       add_charsets = ListOfCharsets
356              Specifies one or more mappings between charsets and file  exten‐
357              sions.  More  than  one  extension can be assigned to a charset.
358              ListOfCharsets is defined as follows:
359
360                add_charsets = <Charset1, Ext> <Charset2, Ext1 Ext2 ...> ...
361
362              The mappings defined using  this  directive  will  overload  all
363              other definitions. If a file extension is defined several times,
364              only the last one is kept. Multiple add_charsets directives  may
365              be used.
366
367
368       sni = disable | enable | strict
369              Enables  or  disables  the TLS SNI (Server Name Indication) sup‐
370              port.
371
372              When disabled (or not supported), all  virtual  servers  in  the
373              same group (same IP/Port) must share the same SSL configuration,
374              especially the same SSL certificate. Only the HTTP  Host  header
375              will be considered to find the right virtual server.
376
377              When  enabled, SSL configuration can be different from a virtual
378              server to another, each one can have its own SSL certificate. In
379              this  case, if a client provides a SNI hostname, it will be used
380              to find the right virtual server. To accept the SNI  information
381              from  the client, The first virtual server (the default one, see
382              pick_first_virthost_on_nomatch) must include TLS as a  permitted
383              protocol.
384
385              If  sni directive is set to enable, non SNI clients are allowed.
386              For such clients, virtual servers are selected as  if  Yaws  did
387              not  have  SNI  support. If it is set to strict, SNI hostname is
388              mandatary to access a SSL virtual server.  But,  in  all  cases,
389              when  SNI  support  is enabled, if a client provides a SNI host‐
390              name, it must match the HTTP Host  header  (which  is  mandatory
391              too).  Note that the first virtual server (the default one) will
392              be used for any request where the provided SNI hostname  doesn't
393              match  any of virtual server names. So, it is important that the
394              first virtual server have the most restrictive  access  control,
395              otherwise  clients  can access restricted resources by sending a
396              request for any unknown hostname. (This isn't actually any  dif‐
397              ferent from using virtual servers without SNI support.)
398
399              The  sni  directive is a global one, so if you set it to strict,
400              non SNI  clients  will  be  refused  for  all  SSL  groups.  See
401              require_sni  directive  from  the  server  part to mitigate this
402              requirement.
403
404              Default is disable.
405
406              WARNING: The SNI support was introduced in the  SSL  application
407              in Erlang/OTP 18.0, so Yaws ignores it for previous releases.
408
409

SERVER PART

411       Yaws can virthost several web servers on the same IP address as well as
412       several web servers  on  different  IP  addresses.  This  includes  SSL
413       servers.
414
415       Each  virtual host is defined within a matching pair of <server Server‐
416       Name> and </server>. The ServerName will be the name of the webserver.
417
418
419       The following directives are allowed inside a server definition.
420
421       port = Port
422              This makes the server listen on Port. Default is 8000.
423
424       listen = IpAddress
425              This makes the server listen  on  IpAddress.   When  virthosting
426              several  servers  on  the  same  ip/port address, if the browser
427              doesn't send a Host: field, Yaws  will  pick  the  first  server
428              specified  in  the  config file.  If the specified IP address is
429              0.0.0.0 Yaws will listen on all local IP addresses on the speci‐
430              fied port. Default is 127.0.0.1.  Multiple listen directives may
431              be used to specify several addresses to listen on.
432
433
434       listen_backlog = Integer
435              This sets the TCP listen backlog for the server  to  define  the
436              maximum length the queue of pending connections may grow to. The
437              default is 1024.
438
439
440       <listen_opts> ... </listen_opts>
441              Defines extra options to be set on the  listen  socket  and,  by
442              inheritance,   on   accepted  sockets.  See  inet:setopts/2  for
443              details. Supported options are:
444
445              buffer = Integer (default: same as inet:setopts/2)
446
447              delay_send = true  | false  (default: same as inet:setopts/2)
448
449              linger = Integer | false  (default: same as inet:setopts/2)
450
451              nodelay = true | false  (default: same as inet:setopts/2)
452
453              priority = Integer (default: same as inet:setopts/2)
454
455              sndbuf = Integer (default: same as inet:setopts/2)
456
457              recbuf = Integer (default: same as inet:setopts/2)
458
459              send_timeout  =   Integer   |   infinity   (default:   same   as
460              inet:setopts/2)
461
462              send_timeout_close   =   true   |   false    (default:  same  as
463              inet:setopts/2)
464
465
466       server_signature = String
467              This directive sets the "Server: " output header to  the  custom
468              value and overloads the global one for this virtual server.
469
470
471       subconfig = File
472              Same  as  subconfig directive of the global part, but here files
473              should only contain directives allowed in the server part.
474
475
476
477       subconfigdir = Directory
478              Same as subconfigdir directive of  the  global  part,  but  here
479              files should only contain directives allowed in server part.
480
481
482       rhost = Host[:Port]
483              This  forces  all  local redirects issued by the server to go to
484              Host.  This is useful when Yaws listens to a port which is  dif‐
485              ferent  from  the  port  that the user connects to. For example,
486              running Yaws as a non-privileged user  makes  it  impossible  to
487              listen to port 80, since that port can only be opened by a priv‐
488              ileged user. Instead Yaws listens to a high  port  number  port,
489              8000,  and  iptables  are used to redirect traffic to port 80 to
490              port 8000 (most NAT:ing firewalls will also do this for you).
491
492
493       rmethod = http | https
494              This forces all local redirects issued by the server to use this
495              method.  This  is  useful when an SSL off-loader, or stunnel, is
496              used in front of Yaws.
497
498
499       auth_log  = true | false
500              Enable or disable the auth log for this virtual server.  Default
501              is true.
502
503
504       access_log = true | false
505              Setting  this  directive  to false turns off traffic logging for
506              this virtual server. The default value is true.
507
508
509       logger_mod = Module
510              It is possible to set a special module that handles  access  and
511              auth  logging.  The  default is to log all web server traffic to
512              <Host>.access and <Host>.auth files in the configured or default
513              logdir.
514              This  module  must  implement the behaviour yaws_logger. Default
515              value is yaws_log.
516
517              The following functions should be exported:
518
519              Module:open_log(ServerName, Type, LogDir)
520                   When Yaws is started, this function is called for this vir‐
521                   tual server. If the initialization is successful, the func‐
522                   tion must return {true,State} and if an error occurred,  it
523                   must return false.
524
525
526              Module:close_log(ServerName, Type, State)
527                   This  function  is called for this virtual server when Yaws
528                   is stopped.
529
530
531              Module:wrap_log(ServerName, Type, State, LogWrapSize)
532                   This function is used to rotate log files. It is  regularly
533                   called  by Yaws and must return the possibly updated inter‐
534                   nal NewState.
535
536
537              Module:write_log(ServerName, Type, State, Infos)
538                   When it needs to log a message, Yaws will call  this  func‐
539                   tion.  The  parameter Infos is {Ip,Req,InHdrs,OutHdrs,Time}
540                   for an access log  and  {Ip,Path,Item}  for  an  auth  log,
541                   where:
542
543                   Ip - IP address of the accessing client (as a tuple).
544
545                   Req  -  the  HTTP method, URI path, and HTTP version of the
546                   request (as a #http_request{} record).
547
548                   InHdrs - the HTTP headers which were received from the  WWW
549                   client (as a #headers{} record).
550
551                   OutHdrs  -  the  HTTP  headers sent to the WWW client (as a
552                   #outh{} record)
553
554                   Path - the URI path of the request (as a string).
555
556                   Item - the result of  an  authentication  request.  May  be
557                   {ok,User}, 403 or {401,Realm}.
558
559                   Time  -  The  time taken to serve the request, in microsec‐
560                   onds.
561
562
563              For all of these callbacks, ServerName is the  virtual  server's
564              name,  Type is the atom access or auth and State is the internal
565              state of the logger.
566
567
568       shaper = Module
569              Defines a module to  control  access  to  this  virtual  server.
570              Access  can be controlled based on the IP address of the client.
571              It is also possible to  throttle  HTTP  requests  based  on  the
572              client's download rate. This module must implement the behaviour
573              yaws_shaper.
574
575              There is no such module configured by default.
576
577
578       dir_listings = true | true_nozip | false
579              Setting this directive to  false  disallows  the  automatic  dir
580              listing  feature  of  Yaws.  A status code 403 Forbidden will be
581              sent.  Set to true_nozip to  avoid  the  auto-generated  all.zip
582              entries. Default is false.
583
584
585       extra_cgi_vars = .....
586              Add additional CGI or FastCGI variables. For example:
587
588                <extra_cgi_vars dir='/path/to/some/scripts'>
589                  var = val
590                  ...
591                </extra_cgi_vars>
592
593
594       statistics  = true | false
595              Turns  on/off statistics gathering for a virtual server. Default
596              is false.
597
598
599       fcgi_app_server = Host:Port
600              The hostname and  TCP  port  number  of  a  FastCGI  application
601              server.  To specify an IPv6 address, put it inside square brack‐
602              ets (ex: "[::1]:9000"). The TCP port  number  is  not  optional.
603              There is no default value.
604
605
606       fcgi_trace_protocol = true | false
607              Enable  or  disable tracing of FastCGI protocol messages as info
608              log messages. Disabled by default.
609
610
611       fcgi_log_app_error = true | false
612              Enable or disable logging of application error messages  (output
613              to stderr and non-zero exit value). Disabled by default.
614
615
616       deflate = true | false
617              Turns  on  or  off  deflate compression for a server. Default is
618              false.
619
620
621
622       <deflate> ... </deflate>
623              This begins and ends the deflate compression  configuration  for
624              this  server.  The following items are allowed within a matching
625              pair of <deflate> and </deflate> delimiters.
626
627              min_compress_size = nolimit | Integer
628                   Defines the smallest response size that will be compressed.
629                   If  nolimit  is  not  used,  the  specified  value  must be
630                   strictly positive. The default value is nolimit.
631
632
633              compression_level  =  none  |  default  |   best_compression   |
634              best_speed | 0..9
635                   Defines  the  compression level to be used. 0 (none), gives
636                   no compression at all, 1 (best_speed) gives best speed  and
637                   9  (best_compression)  gives  best compression. The default
638                   value is default.
639
640
641              window_size = 9..15
642                   Specifies the zlib compression window size. It should be in
643                   the  range  9  through  15. Larger values of this parameter
644                   result in better  compression  at  the  expense  of  memory
645                   usage. The default value is 15.
646
647
648              mem_level = 1..9
649                   Specifies  how  much  memory  should  be  allocated for the
650                   internal compression state. mem_level=1 uses minimum memory
651                   but is slow and reduces compression ratio; mem_level=9 uses
652                   maximum memory for optimal speed. The default value is 8.
653
654
655              strategy = default | filtered | huffman_only
656                   This parameter is used to tune the  compression  algorithm.
657                   See  zlib(3erl) for more details on the strategy parameter.
658                   The default value is default.
659
660
661              use_gzip_static = true | false
662                   If true, Yaws will try to serve precompressed  versions  of
663                   static  files.  It will look for precompressed files in the
664                   same location as original files that  end  in  ".gz".  Only
665                   files  that  do  not  fit  in  the cache are concerned. The
666                   default value is false.
667
668
669              mime_types = ListOfTypes | defaults | all
670                   Restricts the deflate compression to particular MIME types.
671                   The special value all enable it for all types (It is a syn‐
672                   onym of `*/*'). MIME types into ListOfTypes must  have  the
673                   form `type/subtype' or `type/*' (indicating all subtypes of
674                   that type). Here is an example:
675
676                     mime_types = default image/*
677                     mime_types = application/xml application/xhtml+xml application/rss+xml
678
679                   By default, the following MIME  types  are  compressed  (if
680                   deflate  is set to true): text/*, application/rtf, applica‐
681                   tion/msword, application/pdf,  application/x-dvi,  applica‐
682                   tion/javascript,     application/x-javascript.     Multiple
683                   mime_types directive can be used.
684
685
686       docroot = Directory ...
687              This makes the server serve all its content from Directory.
688              It is possible to pass a space-separated list of directories  as
689              docroot.  If  this  is the case, the various directories will be
690              searched in order for the requested file. This also  works  with
691              the  ssi  and yssi constructs where the full list of directories
692              will be searched for files to ssi/yssi include. Multiple docroot
693              directives  can  be  used.  You need at least one valid docroot,
694              invalid docroots are skipped with their associated  auth  struc‐
695              tures.
696
697
698       auth_skip_docroot = true | false
699              If  true, the docroot will not be searched for .yaws_auth files.
700              This is useful when the docroot is quite large and the  time  to
701              search it is prohibitive when Yaws starts up. Defaults to false.
702
703
704       partial_post_size = Integer | nolimit
705              When  a  Yaws  file  receives  large  POSTs,  the amount of data
706              received in each chunk is determined  by  this  parameter.   The
707              default  value  is  10240.  Setting it to nolimit is potentially
708              dangerous.
709
710
711
712       dav = true | false
713              Turns on the DAV protocol for this server. The  dav  support  in
714              Yaws is highly limited. If dav is turned on, .yaws processing of
715              .yaws pages is turned off. Default is  false.  The  socket  read
716              timeout  is  supplied  by the keepalive_timeout setting.  If the
717              read is not done within the timeout, the POST will fail.
718
719
720       tilde_expand = true|false
721              If this value is set to false Yaws will never  do  tilde  expan‐
722              sion.  The  default  is  false. tilde_expansion is the mechanism
723              whereby  a  URL  on  the  form  http://www.foo.com/~username  is
724              changed  into  a  request  where the docroot for that particular
725              request is set to the directory ~username/public_html/.
726
727
728       allowed_scripts = ListOfSuffixes
729              The allowed  script  types  for  this  server.   Recognized  are
730              `yaws', `cgi', `fcgi', `php'.  Default is allowed_scripts = yaws
731              php cgi fcgi.
732
733              Note: for fcgi scripts, the FastCGI application server  is  only
734              called if a local file with the .fcgi extension exists. However,
735              the contents of the local .fcgi file are ignored.
736
737
738       tilde_allowed_scripts = ListOfSuffixes
739              The allowed script types for this server when executing files in
740              a users public_html folder Recognized are `yaws', `cgi', `fcgi',
741              `php'.  Default is tilde_allowed_scripts = i.e. empty
742
743
744       index_files = ListOfResources
745              This directive sets the list of resources to look  for,  when  a
746              directory  is  requested by the client. If the last entry begins
747              with a `/', and none of the earlier resources  are  found,  Yaws
748              will  perform  a redirect to this uri.  Default is index_files =
749              index.yaws index.html index.php.
750
751
752       appmods = ListOfModuleNames
753              If any of the names in ListOfModuleNames appear as components in
754              the  path for a request, the path request parsing will terminate
755              and that module will be called. There is also an alternate  syn‐
756              tax  for  specifying  the  appmods if we don't want our internal
757              erlang module names to be exposed in  the  URL  paths.   We  can
758              specify
759
760                appmods = <Path1, Module1> <Path2, Modules2> ...
761
762              Assume     for     example     that     we    have    the    URL
763              http://www.hyber.org/myapp/foo/bar/baz?user=joe  while  we  have
764              the  module  foo defined as an appmod, the function foo:out(Arg)
765              will be invoked instead of searching the filesystems  below  the
766              point foo.
767              The Arg argument will have the missing path part supplied in its
768              appmoddata field.
769
770              It is also possible to exclude certain directories  from  appmod
771              processing.  This  is  particulaly  interesting for '/' appmods.
772              Here is an example:
773
774                appmods = </, myapp exclude_paths icons js top/static>
775
776              The above configuration will invoke the 'myapp' erlang module on
777              everything  except  any  file found in directories 'icons', 'js'
778              and 'top/static' relative to the docroot.
779
780
781       dispatchmod = DispatchModule
782              Set DispatchModule as a server-specific request dispatching mod‐
783              ule.  Yaws  expects  DispatchModule to export a dispatch/1 func‐
784              tion. When it receives a request, Yaws passes an  #arg{}  record
785              to  the dispatch module's dispatch/1 function, which returns one
786              of the following atom results:
787
788                   done - this  indicates  the  dispatch  module  handled  the
789                   request  itself  and  already  sent  the response, and Yaws
790                   should resume watching for new requests on the connection
791
792                   closed - same as done but the  DispatchModule  also  closed
793                   the connection
794
795                   continue  -  the  dispatch module has decided not to handle
796                   the request, and instead wants Yaws to perform its  regular
797                   request dispatching
798
799
800              Note  that  when  DispatchModule  handles a request itself, Yaws
801              does not support tracing, increment statistics counters or allow
802              traffic  shaping  for  that  request. It does however still keep
803              track of maximum keepalive uses on the connection.
804
805
806       errormod_404 = Module
807              It is possible to set a special  module  that  handles  404  Not
808              Found  messages. The function Module:out404(Arg, GC, SC) will be
809              invoked. The arguments are
810
811                   Arg - a #arg{} record
812
813                   GC - a #gconf{} record (defined in yaws.hrl)
814
815                   SC - a #sconf{} record (defined in yaws.hrl)
816
817
818              The function can and must do the same things that a normal out/1
819              does.
820
821
822       errormod_401 = Module
823              It is possible to set a special module that handles 401 Unautho‐
824              rized messages. This can for example be used to display a  login
825              page  instead. The function Module:out401(Arg, Auth, Realm) will
826              be invoked. The arguments are
827
828                   Arg - a #arg{} record
829
830                   Auth - a #auth{} record
831
832                   Realm - a string
833
834
835              The function can and must do the same things that a normal out/1
836              does.
837
838
839       errormod_crash = Module
840              It  is  possible  to  set a special module that handles the HTML
841              generation of server crash messages. The default is  to  display
842              the  entire formatted crash message in the browser. This is good
843              for debugging but not in production.
844              The function Module:crashmsg(Arg, SC, Str) will be  called.  The
845              Str is the real crash message formatted as a string.
846              The function must return, {content,MimeType,Cont} or {html, Str}
847              or {ehtml, Term}. That data will be shipped to the client.
848
849
850       expires = ListOfExpires
851              Controls the setting of the Expires HTTP header and the  max-age
852              directive  of  the Cache-Control HTTP header in server responses
853              for specific MIME types. The expiration date can be set as rela‐
854              tive  to  either  the time the source file was last modified; as
855              the time of the client access; or as always in  order  to  empty
856              the cache altogether. ListOfExpires is defined as follows:
857
858                expires = <MimeType1, access+Seconds> <MimeType2, modify+Seconds> <MimeType3, always> ...
859
860              A  MimeType  can also have a wildcard as subtype or both as sub‐
861              type and type, like type/* or */*.
862
863              These HTTP headers are an instruction to the  client  about  the
864              document's validity and persistence. If cached, the document may
865              be fetched from the cache rather than from the source until this
866              time  has  passed.  After  that,  the  cache  copy is considered
867              "expired" and invalid, and a new copy must be obtained from  the
868              source. Here is an example:
869
870                expires = <image/gif, access+2592000> <image/png, access+2592000>
871                expires = <image/jpeg, access+2592000> <text/css, access+2592000>
872                expires = <text/*, always>
873
874              and here is another:
875
876                expires = <*/*, always>
877
878
879       arg_rewrite_mod = Module
880              It  is  possible  to  install a module that rewrites all the Arg
881              #arg{} records at an early stage in the Yaws server.   This  can
882              be  used to do various things such as checking a cookie, rewrit‐
883              ing paths etc. An arg_rewrite_mod must export  an  arg_rewrite/1
884              function  taking and returning an #arg{} record. If the function
885              wants to return a response, it must set the #arg.state field  of
886              its  return  value  to  an  instance  of the #rewrite_response{}
887              record.
888
889              The module yaws_vdir can be used  in  case  you  want  to  serve
890              static  content  that  is  not  located in your docroot. See the
891              example at the bottom of this man page for how to use the opaque
892              +  vdir  elements to instruct the yaws_vdir module what paths to
893              rewrite.
894
895
896       start_mod = Module
897              Defines a user provided callback  module.   At  startup  of  the
898              server,  Module:start/1  will  be  called.   The #sconf{} record
899              (defined in yaws.hrl) will be used as the input  argument.  This
900              makes  it  possible  for  a  user application to synchronize the
901              startup with the Yaws server as well as  getting  hold  of  user
902              specific   configuration  data,  see  the  explanation  for  the
903              <opaque> context.
904
905
906       revproxy = Prefix Url [intercept_mod Module]
907              Make Yaws a reverse proxy. Prefix is a path inside our own  doc‐
908              root  and Url argument is a URL pointing to a website we want to
909              "mount" under the Prefix path. This example:
910
911                revproxy = /tmp/foo http://yaws.hyber.org
912
913              makes the hyber website appear under /tmp/foo.
914
915              It is possible to have multiple reverse proxies inside the  same
916              server.
917
918              You  can  optionally  configure  an interception module for each
919              reverse proxy, allowing your application to examine  and  modify
920              requests  and  HTTP  headers as they pass through the proxy from
921              client to backend server and also examine and  modify  responses
922              and  HTTP headers as they return from the backend server through
923              the proxy to the client.
924
925              You specify an interception module  by  including  the  optional
926              intercept_mod  keyword  followed  by Module, which should be the
927              name of your interception module.
928
929              An interception module is expected to export two functions:  re‐
930              write_request/2 and rewrite_response/2. The two arguments passed
931              to rewrite_request/2 function are a #http_request{} record and a
932              #headers{}  record,  whereas rewrite_response/2 function takes a
933              #http_response{} record and also a #headers{}  record.  You  can
934              find  definitions  for  these  record  types in the yaws_api.hrl
935              header file. Each function can examine each record instance  and
936              can  either  return each original instance or can return a modi‐
937              fied  copy  of  each  instance  in   its   response.   The   re‐
938              write_request/2  function should return a tuple of the following
939              form:
940
941                {ok, #http_request{}, #headers{}}
942
943              and the rewrite_response/2 function should  similarly  return  a
944              tuple of the following form:
945
946                {ok, #http_response{}, #headers{}}
947
948              A  #headers{} record can easily be manipulated in an interceptor
949              using the functions listed below:
950
951                yaws_api:set_header/2, yaws_api:set_header/3
952                yaws_api:get_header/2, yaws_api:get_header/3
953                yaws_api:delete_header/2
954
955              Any failures in your interception module's functions will result
956              in HTTP status code 500, indicating an internal server error.
957
958
959       fwdproxy = true|false
960              Make  Yaws  a forward proxy. By enabling this option you can use
961              Yaws as a proxy for outgoing web traffic, typically by configur‐
962              ing  the  proxy  settings  in a web-browser to explicitly target
963              Yaws as its proxy server.
964
965
966       servername = Name
967              If we're virthosting several servers and want to force a  server
968              to match specific Host: headers we can do this with the "server‐
969              name" directive. This name doesn't necessarily have  to  be  the
970              same as the the name inside <server Name> in certain NAT scenar‐
971              ios. Rarely used feature.
972
973
974       serveralias = ListOfNames
975
976              This directive sets the alternate names for a  virtual  host.  A
977              server alias may contain wildcards:
978                    '*' matches any sequence of zero or more characters
979                    '?'  matches  one  character  unless  that  character is a
980                   period ('.')
981
982              Multiple serveralias directives may be used. Here is an example:
983
984                <server server.domain.com>
985                  serveralias = server server2.domain.com server2
986                  serveralias = *.server.domain.com *.server?.domain.com
987                  ...
988                </server>
989
990
991
992       php_handler = <Type, Spec>
993              Set handler to interpret .php files. It can be one of  the  fol‐
994              lowing definitions:
995
996              php_handler  =  <cgi, Filename> - The name of (and possibly path
997              to) the  php  executable  used  to  interpret  php  scripts  (if
998              allowed).
999
1000              php_handler  =  <fcgi,  Host:Port>  -  Use the specified fastcgi
1001              server to interpret .php files (if allowed).
1002
1003                   Yaws does not start the PHP interpreter in fastcgi mode for
1004                   you.  To  run  PHP  in  fastcgi  mode,  call it with the -b
1005                   option. For example:
1006
1007                     php5-cgi -b '127.0.0.1:54321'
1008
1009                   This starts a php5 in fastcgi mode listening on  the  local
1010                   network  interface.  To  make  use  of this PHP server from
1011                   Yaws, specify:
1012
1013                     php_handler = <fcgi, 127.0.0.1:54321>
1014
1015                   If you need to specify an IPv6 address, use  square  brack‐
1016                   ets:
1017
1018                     php_handler = <fcgi, [::1]:54321>
1019
1020                   The PHP interpreter needs read access to the files it is to
1021                   serve. Thus, if you run it in a different security  context
1022                   than  Yaws  itself,  make  sure  it  has access to the .php
1023                   files.
1024                   Please note that anyone who is able to connect to  the  php
1025                   fastcgi  server  directly  can  use  it to read any file to
1026                   which it has read access. You  should  consider  this  when
1027                   setting   up  a  system  with  several  mutually  untrusted
1028                   instances of php.
1029
1030
1031              php_handler = <extern, Module:Function | Node:Module:Function> -
1032              Use  an external handler, possibly on another node, to interpret
1033              .php files (if allowed).
1034
1035                   To interpret a .php file, the function Module:Function(Arg)
1036                   will  be  invoked (Evaluated inside a rpc call if a Node is
1037                   specified), where Arg is an #arg{} record.
1038                   The function must do the same things that  a  normal  out/1
1039                   does.
1040
1041
1042              Default value is <cgi, "/usr/bin/php-cgi">.
1043
1044
1045       phpfcgi = Host:Port
1046              this  target  is  deprecated. use 'php_handler' target in server
1047              part instead.
1048              Using this directive  is  the  same  as:  php_handler  =  <fcgi,
1049              Host:Port>.
1050
1051
1052       default_type = MimeType
1053              Overloads the global default_type value for this virtual server.
1054
1055       default_charset = Charset
1056              Overloads  the  global  default_charset  value  for this virtual
1057              server.
1058
1059
1060       mime_types_file = File
1061              Overloads the  global  mime_type_file  value  for  this  virtual
1062              server. Mappings defined in File will not overload those defined
1063              by add_types directives in the global part.
1064
1065
1066       add_types = ListOfTypes
1067              Overloads the global add_types values for this  virtual  server.
1068              If  a  mapping  is defined in the global part and redefined in a
1069              server part using this directive, then it is replaced.  Else  it
1070              is kept.
1071
1072
1073       add_charsets = ListOfCharsets
1074              Overloads  the  global  add_charsets  values  for  this  virtual
1075              server. If a mapping is defined in the global part and redefined
1076              in a server part using this directive, then it is replaced. Else
1077              it is kept.
1078
1079
1080       nslookup_pref = [inet | inet6]
1081              For fcgi servers and revproxy URLs, define the  name  resolution
1082              preference.  For  example, to perform only IPv4 name resolution,
1083              use [inet]. To do both IPv4 and IPv6 but  try  IPv6  first,  use
1084              [inet6, inet].  Default value is [inet].
1085
1086
1087       <ssl> ... </ssl>
1088
1089              This  begins and ends an SSL configuration for this server. It's
1090              possible to virthost several SSL servers on the same IP/Port. If
1091              SNI  support  is  disabled or not supported, they must share the
1092              same certificate configuration. In this situation, it is compli‐
1093              cated  to virthost several SSL servers on the same IP/Port since
1094              the certificate is typically bound to a domainname in the common
1095              name part of the certificate. One solution to this problem is to
1096              have a certificate with multiple subjectAltNames. If SNI support
1097              is  enabled,  SSL servers on the same IP/Port can have their own
1098              SSL configuration with a different SSL certificate for each one.
1099              See the global sni directive.
1100
1101              The  SNI  support  was  introduced  in  the  SSL  application in
1102              Erlang/OTP 18.0. It is an extension to  the  TLS  protocol  (RFC
1103              4366), which allows the client to include the requested hostname
1104              in the first message of its SSL handshake.
1105
1106              See  also   http://wiki.cacert.org/VhostTaskForce#Interoperabil‐
1107              ity_Test for browser compatibility.
1108
1109              keyfile = File
1110                   Specifies  which file contains the private key for the cer‐
1111                   tificate. If not specified then the certificate  file  will
1112                   be used.
1113
1114
1115              certfile = File
1116                   Specifies  which  file  contains  the  certificate  for the
1117                   server.
1118
1119
1120              cacertfile = File
1121                   A file containing trusted certificates to use during client
1122                   authentication  and  to  use  when  attempting to build the
1123                   server certificate chain.  The list is  also  used  in  the
1124                   list  of  acceptable client CAs passed to the client when a
1125                   certificate is requested.
1126
1127
1128              dhfile = File
1129                   A file containing PEM-encoded Diffie-Hellman parameters  to
1130                   be  used by the server if a cipher suite using Diffie-Hell‐
1131                   man key exchange is negotiated. If not  specified,  default
1132                   parameters are used.
1133
1134
1135              verify = verify_none | verify_peer
1136                   Specifies  the  level  of  verification  the server does on
1137                   client certs. Setting verify_none means that the x509 vali‐
1138                   dation  will  be skipped (no certificate request is sent to
1139                   the client), verify_peer means that a  certificate  request
1140                   is sent to the client (x509 validation is performed.
1141
1142                   You  might  want to use fail_if_no_peer_cert in combination
1143                   with verify_peer.
1144
1145
1146              fail_if_no_peer_cert = true | false
1147                   If verify is set to verify_peer and set to true the connec‐
1148                   tion  will  fail  if the client does not send a certificate
1149                   (i.e. an empty certificate). If set  to  false  the  server
1150                   will  fail  only  if an invalid certificate is supplied (an
1151                   empty certificate is considered valid).
1152
1153
1154              depth = Int
1155                   Specifies the depth of certificate  chains  the  server  is
1156                   prepared to follow when verifying client certs. For the OTP
1157                   new SSL implementation it is also used to specify  how  far
1158                   the  server,  i.e. we, shall follow the SSL certificates we
1159                   present to the clients. Hence, using self-signed certs,  we
1160                   typically need to set this to 0.
1161
1162
1163              password = String
1164                   If  the  private key is encrypted on disc, this password is
1165                   the 3DES key to decrypt it.
1166
1167
1168              ciphers = String
1169                   This string specifies the SSL cipher string. The syntax  of
1170                   the SSL cipher string is  an erlang term compliant with the
1171                   output of ssl:cipher_suites().
1172
1173                   ciphers = "[{dhe_rsa,aes_256_cbc,sha}, \
1174                               {dhe_dss,aes_256_cbc,sha}]"
1175
1176
1177              secure_renegotiate = true | false
1178                   Specifies whether to reject renegotiation attempt that does
1179                   not  live  up to RFC 5746. By default secure_renegotiate is
1180                   set to false i.e. secure renegotiation will be used if pos‐
1181                   sible but it will fallback to unsecure renegotiation if the
1182                   peer does not support RFC 5746.
1183
1184
1185              client_renegotiation = true | false
1186                   Enables or disables the Erlang/OTP SSL  application  client
1187                   renegotiation  option. Defaults to true. See the ssl manual
1188                   page  at  http://www.erlang.org/doc/man/ssl.html  for  more
1189                   details.
1190
1191                   WARNING:  This option was introduced in the SSL application
1192                   in  Erlang/OTP  18.0,  so  Yaws  ignores  it  for  previous
1193                   releases.
1194
1195
1196              honor_cipher_order = true | false
1197                   If  true  (the  default),  use  the server's preference for
1198                   cipher selection. If false, use the client's preference.
1199
1200                   WARNING: This option was introduced in the SSL  application
1201                   in  Erlang/OTP  17.0,  so  Yaws  ignores  it  for  previous
1202                   releases.
1203
1204
1205              protocol_version = ProtocolList
1206                   Specifies the list of SSL protocols that will be supported.
1207                   If  not  set,  defaults  to  all protocols supported by the
1208                   erlang ssl application. For example, to  support  only  TLS
1209                   versions 1.2, 1.1, and 1:
1210
1211                   protocol_version = tlsv1.2, tlsv1.1, tlsv1
1212
1213
1214              require_sni = true | false
1215                   If  true,the server will reject non SNI clients and clients
1216                   providing an unknown SNI hostname (this last remark is only
1217                   relevant for the first virtual server of a SSL group). This
1218                   directive is ignored if SNI support  is  disabled  (or  not
1219                   supported).
1220
1221                   Default is false.
1222
1223
1224       <redirect> ... </redirect>
1225              Defines  a  redirect  mapping.  The  following items are allowed
1226              within a matching pair of <redirect> and </redirect> delimiters.
1227
1228              We can have a series of redirect rules in  one  of  the  formats
1229              below:
1230
1231                Path = URL
1232                Path = code
1233                Path = code URL
1234
1235              Path must be an url-decoded path beginning with a slash. URL may
1236              be either a relative URL (a path beginning with a slash), or  an
1237              absolute URL. In the first case, the scheme:hostname:port of the
1238              current server will be added. All accesses to Path will be redi‐
1239              rected  to  URL/Path (or scheme:hostname:port/URL/Path if URL is
1240              relative). URL must be url-encoded. Note that the original  path
1241              is appended to the redirected URL.
1242
1243              For  example,  assume  we have the following redirect configura‐
1244              tion:
1245
1246                <redirect>
1247                  /foo = http://www.mysite.org/zapp
1248                  /bar = /tomato.html
1249                </redirect>
1250
1251              Assuming this config resides on a site called http://abc.com, we
1252              have the following redirects:
1253
1254                http://abc.com/foo -> http://www.mysite.org/zapp/foo
1255                http://abc.com/foo/test -> http://www.mysite.org/zapp/foo/test
1256                http://abc.com/bar -> http://abc.com/tomato.html/bar
1257                http://abc.com/bar/x/y/z -> http://abc.com/tomato.html/bar/x/y/z
1258
1259              By  default,  Yaws  will perform a 302 redirect. The HTTP status
1260              code can be changed using the code parameter. Note that the sta‐
1261              tus code must be known by Yaws.
1262
1263              ·  For  3xx  status codes, the URL parameter must be present and
1264                 will be used to build the new location.
1265
1266              ·  For other status codes (1xx, 2xx, 4xx and  5xx),  it  can  be
1267                 omitted.  In  the  absence of URL, Yaws will return a generic
1268                 response with the specified status code.
1269
1270              ·  Otherwise, the URL parameter must be a relative URL and  will
1271                 be used to customize the response.
1272
1273              Sometimes  we  do not want to have the original path appended to
1274              the redirected path. To get that behaviour we specify the config
1275              with '==' instead of '='.
1276
1277                <redirect>
1278                  /foo == http://www.mysite.org/zapp
1279                  /bar = /tomato.html
1280                </redirect>
1281
1282              Now  a  request  for  http://abc.com/foo/x/y/z simply gets redi‐
1283              rected to http://www.mysite.org/zapp.  This  is  typically  used
1284              when  we simply want a static redirect at some place in the doc‐
1285              root.
1286
1287              When we specify a relative URL as the target for  the  redirect,
1288              the redirect will be to the current http(s) server.
1289
1290
1291       <auth> ... </auth>
1292              Defines  an  auth  structure.  The  following  items are allowed
1293              within a matching pair of <auth> and </auth> delimiters.
1294
1295              docroot = Docroot
1296                   If a docroot is defined, this auth structure will be tested
1297                   only for requests in the specified docroot. No docroot con‐
1298                   figured means all docroots.  If  two  auth  structures  are
1299                   defined,  one  with  a docroot and one with no docroot, the
1300                   first of both overrides the second one for requests in  the
1301                   configured docroot.
1302
1303
1304              dir = Dir
1305                   Makes  Dir to be controlled by WWW-authenticate headers. In
1306                   order for a user to have access  to  WWW-Authenticate  con‐
1307                   trolled directory, the user must supply a password. The Dir
1308                   must be specified relative to the  docroot.   Multiple  dir
1309                   can be used. If no dir is set, the default value, "/", will
1310                   be used.
1311
1312
1313              realm = Realm
1314                   In the directory defined here, the  WWW-Authenticate  Realm
1315                   is set to this value.
1316
1317
1318              authmod = AuthMod
1319                   If  an  auth module is defined then AuthMod:auth(Arg, Auth)
1320                   will be called for all access to the directory. The  auth/2
1321                   function should return one of: true, false, {false, Realm},
1322                   {appmod, Mod}.  If {appmod, Mod} is returned then a call to
1323                   Mod:out401(Arg,  Auth,  Realm)  will be used to deliver the
1324                   content. If errormod_401 is defined, the call to  Mod  will
1325                   be ignored. (Mod:out(Arg) is deprecated).
1326
1327                   This  can, for example, be used to implement cookie authen‐
1328                   tication.  The auth()  callback  would  check  if  a  valid
1329                   cookie  header  is present, if not it would return {appmod,
1330                   ?MODULE} and the out401/1 function in the same module would
1331                   return {redirect_local, "/login.html"}.
1332
1333
1334              user      =      User:Password     |     "User:{Algo}Hash"     |
1335              "User:{Algo}$Salt$Hash"
1336                   Inside this directory, the user User has access if the user
1337                   supplies  the  password Password in the popup dialogue pre‐
1338                   sented by the browser. It is also  possible  to  provide  a
1339                   hashed password, encoded in base64. In that case, the algo‐
1340                   rithm used to hash the password must be set. Algo must be a
1341                   one of the following algorithms:
1342
1343                       md5 | ripemd160 | sha | sha224 | sha256 | sha384 | sha512
1344
1345                   It  is  possible to use salted hashes. If so, the Salt must
1346                   be provided, encoded in base64. We can obviously have  sev‐
1347                   eral of these value inside a single <auth> </auth> pair.
1348
1349
1350
1351              pam service = pam-service
1352                   If  the  item  pam is part of the auth structure, Yaws will
1353                   also try to authenticate the user using "pam" using the pam
1354                   service indicated. Usual services are typically found under
1355                   /etc/pam.d. Usual values are "system-auth" etc.
1356
1357                   pam authentication is performed by an Erlang  port  program
1358                   which  is  typically  installed  as  suid  root by the Yaws
1359                   install script.
1360
1361
1362              allow = all | ListOfHost
1363                   The allow directive affects which hosts can access an  area
1364                   of the server. Access can be controlled by IP address or IP
1365                   address range. If all is  specified,  then  all  hosts  are
1366                   allowed  access,  subject  to the configuration of the deny
1367                   and order directives. To allow  only  particular  hosts  or
1368                   groups of hosts to access the server, the host can be spec‐
1369                   ified in any of the following formats:
1370
1371                   A full IP address
1372                     allow = 10.1.2.3
1373                     allow = 192.168.1.104, 192.168.1.205
1374
1375                   A network/netmask pair
1376                     allow = 10.1.0.0/255.255.0.0
1377
1378
1379                   A network/nnn CIDR specification
1380                     allow = 10.1.0.0/16
1381
1382
1383              deny = all | ListOfHost
1384                   This directive allows access to the server to be restricted
1385                   based  on  IP address. The arguments for the deny directive
1386                   are identical to the arguments for the allow directive.
1387
1388
1389              order = Ordering
1390                   The order directive, along with allow and deny  directives,
1391                   controls a three-pass access control system. The first pass
1392                   processes either all allow or all deny directives, as spec‐
1393                   ified  by  the  order directive. The second pass parses the
1394                   rest of the directives (deny  or  allow).  The  third  pass
1395                   applies  to  all  requests which do not match either of the
1396                   first two.
1397
1398                   Ordering is one of (Default value is deny,allow):
1399
1400
1401                   allow,deny
1402                          First, all allow directives are evaluated; at  least
1403                          one  must  match,  or the request is rejected. Next,
1404                          deny directives are evaluated. If any  matches,  the
1405                          request is rejected. Last, any requests which do not
1406                          match an allow or a deny  directive  are  denied  by
1407                          default.
1408
1409
1410                   deny,allow
1411                          First,  all  deny  directives  are evaluated; if any
1412                          matched,  the  request  is  denied  unless  it  also
1413                          matches  an  allow  directive. Any requests which do
1414                          not match any allow or deny directives  are  permit‐
1415                          ted.
1416
1417
1418       <opaque> ... </opaque>
1419              This  begins  and  ends an opaque configuration context for this
1420              server, where 'Key = Value' directives can be  specified.  These
1421              directives  are ignored by Yaws (hence the name opaque), but can
1422              be accessed as a  list  of  tuples  {Key,Value}  stored  in  the
1423              #sconf.opaque  record  entry.  See  also  the description of the
1424              start_mod directive.
1425
1426              This mechanism can be used  to  pass  data  from  a  surrounding
1427              application into the individual .yaws pages.
1428
1429
1430
1431
1432

EXAMPLES

1434       The following example defines a single server on port 80.
1435
1436           logdir = /var/log/yaws
1437           <server www.mydomain.org>
1438               port = 80
1439               listen = 192.168.128.31
1440               docroot = /var/yaws/www
1441           </server>
1442
1443
1444       And  this example shows a similar setup but two web servers on the same
1445       IP address.
1446
1447           logdir = /var/log/yaws
1448           <server www.mydomain.org>
1449               port = 80
1450               listen = 192.168.128.31
1451               docroot = /var/yaws/www
1452           </server>
1453
1454           <server www.funky.org>
1455               port = 80
1456               listen = 192.168.128.31
1457               docroot = /var/yaws/www_funky_org
1458           </server>
1459
1460
1461       An example with www-authenticate and no access logging at all.
1462
1463           logdir = /var/log/yaws
1464           <server www.mydomain.org>
1465               port = 80
1466               listen = 192.168.128.31
1467               docroot = /var/yaws/www
1468               access_log = false
1469               <auth>
1470                   dir = secret/dir1
1471                   realm = foobar
1472                   user = jonny:verysecretpwd
1473                   user = benny:thequestion
1474                   user = ronny:havinganamethatendswithy
1475              </auth>
1476           </server>
1477
1478
1479
1480       An example specifying a user defined module to be called at startup, as
1481       well as some user specific configuration.
1482
1483           <server www.funky.org>
1484               port = 80
1485               listen = 192.168.128.31
1486               docroot = /var/yaws/www_funky_org
1487               start_mod = btt
1488               <opaque>
1489                       mydbdir = /tmp
1490                       mylogdir = /tmp/log
1491               </opaque>
1492           </server>
1493
1494
1495
1496       An  example  specifying the GSSAPI/SPNEGO module (authmod_gssapi) to be
1497       used for authentication. This module requires egssapi version  0.1~pre2
1498       or later available at http://www.hem.za.org/egssapi/.
1499
1500       The  Kerberos5  keytab  is  specified  as  'keytab = File' directive in
1501       opaque. This keytab should contain the keys of the HTTP service princi‐
1502       pal, 'HTTP/www.funky.org' in this example.
1503
1504           <server www.funky.org>
1505               port = 80
1506               listen = 192.168.128.31
1507               docroot = /var/yaws/www_funky_org
1508               start_mod = authmod_gssapi
1509               <auth>
1510                       authmod = authmod_gssapi
1511                       dir = secret/dir1
1512               </auth>
1513               <opaque>
1514                       keytab = /etc/yaws/http.keytab
1515               </opaque>
1516           </server>
1517
1518
1519
1520       And  finally  a  slightly  more complex example with two servers on the
1521       same IP, and one SSL server on a different IP.
1522
1523       When there are more than one server on the same IP, and they have  dif‐
1524       ferent  names  the  server  must  be  able to choose one of them if the
1525       client doesn't send a Host: header. Yaws  will  choose  the  first  one
1526       defined in the conf file.
1527
1528           logdir = /var/log/yaws
1529           max_num_cached_files = 8000
1530           max_num_cached_bytes = 6000000
1531
1532           <server www.mydomain.org>
1533               port = 80
1534               listen = 192.168.128.31
1535               docroot = /var/yaws/www
1536           </server>
1537
1538           <server www.funky.org>
1539               port = 80
1540               listen = 192.168.128.31
1541               docroot = /var/yaws/www_funky_org
1542           </server>
1543
1544           <server www.funky.org>
1545               port = 443
1546               listen = 192.168.128.32
1547               docroot = /var/yaws/www_funky_org
1548               <ssl>
1549                  keyfile = /etc/funky.key
1550                  certfile = /etc/funky.cert
1551                  password = gazonk
1552               </ssl>
1553           </server>
1554
1555
1556
1557       Finally an example with virtual directories, vdirs.
1558
1559           <server server.domain>
1560               port = 80
1561               listen = 192.168.128.31
1562               docroot = /var/yaws/www
1563               arg_rewrite_mod = yaws_vdir
1564               <opaque>
1565                   vdir = "/virtual1/ /usr/local/somewhere/notrelated/to/main/docroot"
1566                   vdir = "/myapp/ /some/other/path can include/spaces"
1567                   vdir = "/icons/  /usr/local/www/yaws/icons"
1568               </opaque>
1569           </server>
1570
1571
1572       The   first   defined   vdir   can   then   be  accessed  at  or  under
1573       http://server.domain/virtual1/ or http://server.domain/virtual1
1574
1575
1576
1577

AUTHOR

1579       Written by Claes Wikstrom
1580

SEE ALSO

1582       yaws(1) erl(1)
1583
1584
1585
1586                                                                  YAWS.CONF(5)
Impressum