⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thttpd.8

📁 修改后的thttp
💻 8
字号:
.TH thttpd 8 "12 October 1995".SH NAMEthttpd - tiny/turbo/throttling HTTP server.SH SYNOPSIS.B thttpd.RB [ -p.IR port ].RB [ -d.IR dir ].RB [ -r | -nor ].RB [ -u.IR user ].RB [ -c.IR cgipat ].RB [ -t.IR throttles ].RB [ -h.IR host ].RB [ -l.IR logfile ].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 -pSpecifies an alternate port number to listen on.The default is 80.Relevant config option: 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.Relevant config options: 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..TP.B -uSpecifies what user to switch to after initialization when started as root.The default is "nobody".Relevant config option: DEFAULT_USER..TP.B -cSpecifies a pattern for CGI programs.See below for details..TP.B -tSpecifies a file of throttle settings.See below for details..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..TP.B -lSpecifies a file for logging.If no file is specified, thttpd logs via syslog()..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..PPRelevant config 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, with ? and *, or 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 options: CGI_PATTERN, CGI_TIMELIMIT, CGI_NICE, CGI_PATH, CGIBINDIR..SH "BASIC AUTHENTICATION".PPBasic Authentication is available as an option at compile time.  If enabled,it uses a password file in a served directory, called .htpasswd by default.This file is formatted as the familiar colon-separatedusername/encrypted-password pair, records delimited by newlines.  Theprotection does not carry over to subdirectories.  The utility programhtpasswd(1) is included to help create and modify .htpasswd files..PPRelevant config option: AUTH_FILE.SH "THROTTLING".PPThe throttle file lets you set maximum byte rates on URLs or URL groups.There is no provision for setting a maximum request rate throttle,because throttling a request uses as much cpu as handling it, sothere would be no point..PPThe 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 ? and *, ormultiple such patterns separated by |..PPThe numbers in the file are byte rates, specified in units of bytes per second.For comparison, a v.32b/v.42b modem gives about 1500/2000 B/sdepending on compression, a double-B-channel ISDN line about12800 B/s, and a T1 line is about 150000 B/s..PPExample:.nf  # throttle file for www.acme.com  *               100000  # limit total web usage to 2/3 of our T1  *.jpg|*.gif     50000   # limit images to 1/3 of our T1  *.mpg           20000   # and movies to even less  jef/*           20000   # jef's pages are too popular.fi.PPThrottling is implemented by checking each incoming URL filename against allof the patterns in the throttle file.The server accumulates statistics on how much bandwidth each patternhas accounted for recently (via a rolling average).If a URL matches a pattern that has been exceeding its specified limit,then the data returned is actually slowed down, withpauses between each block.If that's not possible (e.g. for CGI programs), thenthe server returns a special code saying 'try again later'..SH MULTIHOMINGMultihoming means using one machine to serve multiple hostnames.For instance, if you're an internet provider and you want to letall of your customers have customized web addresses, you mighthave www.joe.acme.com, www.jane.acme.com, and your own www.acme.com,all running on the same physical hardware.This feature is also known as "virtual hosts".There are three steps to setting this up..PPOne, make DNS entries for all of the hostnames.  They should justbe plain old A records, each with a different IP address.Example:.nf  www.acme.com IN A 192.100.66.10  www.joe.acme.com IN A 192.100.66.200  www.jane.acme.com IN A 192.100.66.201.fi.PPTwo, use ifconfig(8)'s alias command to tell the machine's networkinterface to answer to all of the different IP addresses.Example:.nf  ifconfig le0 www.acme.com  ifconfig le0 www.joe.acme.com alias  ifconfig le0 www.jane.acme.com alias.fiIf your OS's version of ifconfig doesn't have an alias command, you'reprobably out of luck (but see http://www.acme.com/software/thttpd/notes.html)..PPThree, run a separate thttpd process for each hostname using the -h flagto specify which one is which.You can also run each of these processes in separate directories,with different throttle files, etc.Example:.nf  thttpd -r -d /usr/www -h www.acme.com -c 'cgi-bin/*' &  thttpd -r -d /usr/www/joe -u joe -h www.joe.acme.com &  thttpd -r -d /usr/www/jane -u jane -h www.jane.acme.com &.fiNote how the company server allows CGI programs, while the others do not.That's a good compromise on the security issue - customers who wantto install CGI programs give them to you for review, and if they're okthen you put them in the company directory..SH SYMLINKS.PPthttpd is very picky about symbolic links.Before delivering any file, it first checks each element in the pathto see if it's a symbolic link, and expands them all out to get the finalactual filename.Along the way it checks for things like links with ".." that go abovethe server's directory, and absolute symlinks (ones that start with a /).These are prohibited as security holes, so the server returns anerror page for them.This means you can't set up your web directory with a bunch of symlinkspointing to individual users' home web directories.Instead you do it the other way around - the user web directories arereal subdirs of the main web directory, and in each user's homedir there's a symlink pointing to their actual web dir..PPThe CGI pattern is also affected - it gets matched against the fully-expandedfilename.  So, if you have a single CGI directory but then put a symboliclink in it pointing somewhere else, that won't work.  The CGI program will betreated as a regular file and returned to the client, instead of getting run.This could be confusing..SH LOGS.PPthttpd does all of its logging via syslog(3).The facility it uses is configurable.Aside from error messages, there are only a few log entry types of interest,all fairly similar to CERN Common Log Format:.nf  Aug  6 15:40:34 acme thttpd[583]: 165.113.207.103 - - "GET /file" 200 357  Aug  6 15:40:43 acme thttpd[583]: 165.113.207.103 - - "HEAD /file" 200 0  Aug  6 15:41:16 acme thttpd[583]: referer http://www.acme.com/ -> /dir  Aug  6 15:41:16 acme thttpd[583]: user-agent Mozilla/1.1N .fiThe package includes a script for translating these log entries infoCERN-compatible files.Note that thttpd does not translate numeric IP addresses into domain names.This is both to save time and as a minor security measure (the numericaddress is harder to spoof)..PPRelevant config option: LOG_FACILITY..PPIf you'd rather log directly to a file, you can use the -l command-lineflag.  But note that error messages still go to syslog..SH "SEE ALSO"nph-redirect(8), ssi(8), makeweb(1), htpasswd(1), syslogtocern(8), weblog_parse(1), http_get(1).SH THANKS.PPMany thanks to reviewers and testers: John LoVerso, Jordan Hayes,Chris Torek, Jim Thompson, Barton Schaffer, Geoff Adams, Daniel Kegel,John Hascall.Special thanks to Craig Leres for substantial debugging and development,and for not complaining about my coding style very much..SH AUTHORCopyright (C)1995,1998 by Jef Poskanzer <jef@acme.com>. All rights reserved..\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\"    notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\"    notice, this list of conditions and the following disclaimer in the.\"    documentation and/or other materials provided with the distribution..\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -