📄 thttpd.8
字号:
.TH thttpd 8 "29 February 2000".SH NAMEthttpd - tiny/turbo/throttling HTTP server.SH SYNOPSIS.B thttpd.RB [ -C.IR configfile ].RB [ -p.IR port ].RB [ -d.IR dir ].RB [ -dd.IR data_dir ].RB [ -r | -nor ].RB [ -s | -nos ].RB [ -v | -nov ].RB [ -g | -nog ].RB [ -u.IR user ].RB [ -c.IR cgipat ].RB [ -t.IR throttles ].RB [ -h.IR host ].RB [ -l.IR logfile ].RB [ -i.IR pidfile ].RB [ -T.IR charset ].RB [ -P.IR P3P ].RB [ -M.IR maxage ].RB [ -V ].RB [ -D ].SH DESCRIPTION.PP.I thttpdis a simple, small, fast, and secure HTTP server.It doesn't have a lot of special features, but it suffices for most uses ofthe web, it's about as fast as the best full-featured servers (Apache, NCSA,Netscape),and it has one extremely useful feature (URL-traffic-based throttling)that no other server currently has..SH OPTIONS.TP.B -CSpecifies a config-file to read.All options can be set either by command-line flags or in the config file.See below for details..TP.B -pSpecifies an alternate port number to listen on.The default is 80.The config-file option name for this flag is "port",and the config.h option is DEFAULT_PORT..TP.B -dSpecifies a directory to chdir() to at startup.This is merely a convenience - you could just as easilydo a cd in the shell script that invokes the program.The config-file option name for this flag is "dir",and the config.h options are WEBDIR, USE_USER_DIR..TP.B -rDo a chroot() at initialization time, restricting file accessto the program's current directory.If -r is the compiled-in default, then -nor disables it.See below for details.The config-file option names for this flag are "chroot" and "nochroot",and the config.h option is ALWAYS_CHROOT..TP.B -ddSpecifies a directory to chdir() to after chrooting.If you're not chrooting, you might as well do a single chdir() withthe -d flag.If you are chrooting, this lets you put the web files in a subdirectoryof the chroot tree, instead of in the top level mixed in with thechroot files.The config-file option name for this flag is "data_dir"..TP.B -nosDon't do explicit symbolic link checking.Normally, thttpd explicitly expands any symbolic links in filenames,to check that the resulting path stays within the original document tree.If you want to turn off this check and save some CPU time, you can usethe -nos flag, however this is not recommended.Note, though, that if you are using the chroot option, the symlinkchecking is unnecessary and is turned off, so the safe way to savethose CPU cycles is to use chroot.The config-file option names for this flag are "symlinkcheck" and "nosymlinkcheck"..TP.B -vDo el-cheapo virtual hosting.If -v is the compiled-in default, then -nov disables it.See below for details.The config-file option names for this flag are "vhost" and "novhost",and the config.h option is ALWAYS_VHOST..TP.B -gUse a global passwd file.This means that every file in the entire document tree is protected bythe single .htpasswd file at the top of the tree.Otherwise the semantics of the .htpasswd file are the same.If this option is set but there is no .htpasswd file inthe top-level directory, then thttpd proceeds as if the option wasnot set - first looking for a local .htpasswd file, and if that doesn'texist either then serving the file without any password.If -g is the compiled-in default, then -nog disables it.The config-file option names for this flag are "globalpasswd" and"noglobalpasswd",and the config.h option is ALWAYS_GLOBAL_PASSWD..TP.B -uSpecifies what user to switch to after initialization when started as root.The default is "nobody".The config-file option name for this flag is "user",and the config.h option is DEFAULT_USER..TP.B -cSpecifies a wildcard pattern for CGI programs, for instance "**.cgi"or "/cgi-bin/*".See below for details.The config-file option name for this flag is "cgipat",and the config.h option is CGI_PATTERN..TP.B -tSpecifies a file of throttle settings.See below for details.The config-file option name for this flag is "throttles"..TP.B -hSpecifies a hostname to bind to, for multihoming.The default is to bind to all hostnames supported on the local machine.See below for details.The config-file option name for this flag is "host",and the config.h option is SERVER_NAME..TP.B -lSpecifies a file for logging.If no -l argument is specified, thttpd logs via syslog().If "-l /dev/null" is specified, thttpd doesn't log at all.The config-file option name for this flag is "logfile"..TP.B -iSpecifies a file to write the process-id to.If no file is specified, no process-id is written.You can use this file to send signals to thttpd.See below for details.The config-file option name for this flag is "pidfile"..TP.B -TSpecifies the character set to use with text MIME types.The default is iso-8859-1.The config-file option name for this flag is "charset",and the config.h option is DEFAULT_CHARSET..TP.B -PSpecifies a P3P server privacy header to be returned with all responses.See http://www.w3.org/P3P/ for details.Thttpd doesn't do anything at all with the string except put it in theP3P: response header.The config-file option name for this flag is "p3p"..TP.B -MSpecifies the number of seconds to be used in a "Cache-Control: max-age"header to be returned with all responses.An equivalent "Expires" header is also generated.The default is no Cache-Control or Expires headers,which is just fine for most sites.The config-file option name for this flag is "max_age"..TP.B -VShows the current version info..TP.B -DThis was originally just a debugging flag, however it's worth mentioningbecause one of the things it does is prevent thttpd from making itselfa background daemon.Instead it runs in the foreground like a regular program.This is necessary when you want to run thttpd wrapped in a little shellscript that restarts it if it exits..SH "CONFIG-FILE".PPAll the command-line options can also be set in a config file.One advantage of using a config file is that the file can be changed,and thttpd will pick up the changes with a restart..PPThe syntax of the config file is simple, a series of "option" or"option=value" separated by whitespace.The option names are listed above with their corresponding command-line flags..SH "CHROOT".PPchroot() is a system call that restricts the program's viewof the filesystem to the current directory and directoriesbelow it.It becomes impossible for remote users to access any fileoutside of the initial directory.The restriction is inherited by child processes, so CGI programs get it too.This is a very strong security measure, and is recommended.The only downside is that only root can call chroot(), so this meansthe program must be started as root.However, the last thing it does during initialization is togive up root access by becoming another user, so this is safe..PPThe program can also be compile-time configured to alwaysdo a chroot(), without needing the -r flag..PPNote that with some other web servers, such as NCSA httpd, settingup a directory tree for use with chroot() is complicated, involvingcreating a bunch of special directories and copying in various files.With thttpd it's a lot easier, all you have to do is make sureany shells, utilities, and config files used by your CGI programs andscripts are available.If you have CGI disabled, or if you make a policy that all CGI programsmust be written in a compiled language such as C and statically linked,then you probably don't have to do any setup at all..PPHowever, one thing you should do is tell syslogd about the chroot tree,so that thttpd can still generate syslog messages.Check your system's syslodg man page for how to do this.In FreeBSD you would put something like this in /etc/rc.conf:.nf syslogd_flags="-l /usr/local/www/data/dev/log".fiSubstitute in your own chroot tree's pathname, of course.Don't worry about creating the log socket, syslogd wants to do that itself.(You may need to create the dev directory.)In Linux the flag is -a instead of -l, and there may be other differences..PPRelevant config.h option: ALWAYS_CHROOT..SH "CGI".PPthttpd supports the CGI 1.1 spec..PPIn order for a CGI program to be run, its name must match the patternspecified either at compile time or on the command line with the -c flag.This is a simple shell-style filename pattern.You can use * to match any string not including a slash,or ** to match any string including slashes,or ? to match any single character.You can also use multiple such patterns separated by |.The patterns get checked against the filenamepart of the incoming URL.Don't forget to quote any wildcard characters so that the shell doesn'tmess with them..PPRestricting CGI programs to a single directory lets the site administratorreview them for security holes, and is strongly recommended.If there are individual users that you trust, you can enable theirdirectories too..PPIf no CGI pattern is specified, neither here nor at compile time,then CGI programs cannot be run at all.If you want to disable CGI as a security measure, that's how you do it, justcomment out the patterns in the config file and don't run with the -c flag..PPNote: the current working directory when a CGI program gets run isthe directory that the CGI program lives in.This isn't in the CGI 1.1 spec, but it's what most other HTTP servers do..PPRelevant config.h options: CGI_PATTERN, CGI_TIMELIMIT, CGI_NICE, CGI_PATH, CGI_LD_LIBRARY_PATH, CGIBINDIR..SH "BASIC AUTHENTICATION".PPBasic Authentication is available as an option at compile time.If enabled, it uses a password file in the directory to be protected,called .htpasswd by default.This file is formatted as the familiar colon-separatedusername/encrypted-password pair, records delimited by newlines.The protection does not carry over to subdirectories.The utility program htpasswd(1) is included to help create andmodify .htpasswd files..PPRelevant config.h option: AUTH_FILE.SH "THROTTLING".PPThe throttle file lets you set maximum byte rates on URLs or URL groups.You can optionally set a minimum rate too.The format of the throttle file is very simple.A # starts a comment, and the rest of the line is ignored.Blank lines are ignored.The rest of the lines should consist of a pattern, whitespace, and a number.The pattern is a simple shell-style filename pattern, using ?/**/*, ormultiple such patterns separated by |..PPThe numbers in the file are byte rates, specified in units of bytes per second.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -