1a4cc7068SAndrzej BialeckiSimple_httpd - A small and free Web server 2a4cc7068SAndrzej Bialecki 3a4cc7068SAndrzej Bialecki"Simple_httpd is like /usr/bin/mail is to mail clients, no frills." 4a4cc7068SAndrzej Bialecki 5a4cc7068SAndrzej BialeckiThis HTTP server can be used in any FreeBSD/PicoBSD application. 6a4cc7068SAndrzej Bialecki 7a4cc7068SAndrzej BialeckiIt has been tested under FreeBSD 2.2.x, 3.x and 4.x. It might work 8a4cc7068SAndrzej Bialeckion other OS systems, but it's for FreeBSD primarily. 9a4cc7068SAndrzej Bialecki 10a4cc7068SAndrzej BialeckiThe main advantage to Simple_httpd is that it is very small. 11a4cc7068SAndrzej BialeckiThe 25K binary can satisfy most needs in a small or embedded 12a4cc7068SAndrzej Bialeckiappplication. If you want a full featured server see 13a4cc7068SAndrzej Bialecki/usr/ports/www/apache* or http://www.apache.org 14a4cc7068SAndrzej Bialecki 15a4cc7068SAndrzej BialeckiSimple_httpd is released under a BSD style copyright that unlike 16a4cc7068SAndrzej BialeckiGPL is embedded developer friendly. 17a4cc7068SAndrzej Bialecki 18a4cc7068SAndrzej BialeckiThe server is designed to be run in one of two modes. The standard 19a4cc7068SAndrzej Bialeckimode is a httpd server running in the background serving up a directory 20a4cc7068SAndrzej Bialeckiof html,gif,cgi whatever. Your traditional www server. 21a4cc7068SAndrzej Bialecki 22a4cc7068SAndrzej BialeckiThe "fetch" mode supports file transfer over httpd. This 23a4cc7068SAndrzej Bialeckiis best thought of as mate for fetch(1). This feature can be 24*b07e9f3fSUlrich Spörleinuseful to transfer a file from one host to another. 25a4cc7068SAndrzej Bialecki 26a4cc7068SAndrzej BialeckiSimple_httpd has the ability to run CGI scripts. All CGI 27a4cc7068SAndrzej Bialeckiscripts must be located in ${DOCUMENT_ROOT}/cgi-bin. The 28*b07e9f3fSUlrich Spörleinserver currently only sets 3 environment variables before calling 29a4cc7068SAndrzej Bialeckithe script. 30a4cc7068SAndrzej Bialecki 31*b07e9f3fSUlrich SpörleinCGI Environment variables are below: 32a4cc7068SAndrzej Bialecki 33a4cc7068SAndrzej BialeckiSERVER_SOFTWARE = FreeBSD/PicoBSD 34a4cc7068SAndrzej BialeckiREMOTE_HOST = client.canada_lower_taxes.com 35a4cc7068SAndrzej BialeckiREMOTE_ADDR = 200.122.13.108 36a4cc7068SAndrzej Bialecki 37a4cc7068SAndrzej BialeckiIn most target applications for this server the extra DNS traffic from 38a4cc7068SAndrzej Bialeckithe remote_addr lookup will likely be on the local lan anyway and not 39a4cc7068SAndrzej Bialeckion the other side of the internet. You can turn it off yourself in 40a4cc7068SAndrzej Bialeckithe code if you want to speed the whole process up. Be sure to turn 41a4cc7068SAndrzej Bialeckiit off for the logfile also. 42c9d8fd0aSAndrzej Bialecki 43f8ee1a07SAndrzej BialeckiHow to use it? 44f8ee1a07SAndrzej Bialecki============== 45c9d8fd0aSAndrzej Bialecki 46a4cc7068SAndrzej BialeckiCompile with make, run as follows 47f8ee1a07SAndrzej Bialecki 48a4cc7068SAndrzej Bialeckiusage: simple_httpd [-vD] 49a4cc7068SAndrzej Bialecki [-d directory] 50a4cc7068SAndrzej Bialecki [-g grpid] 51a4cc7068SAndrzej Bialecki [-l logfile] 52a4cc7068SAndrzej Bialecki [-p port] 53a4cc7068SAndrzej Bialeckior 54a4cc7068SAndrzej Bialeckiusage: simple_httpd [-p port] -f filename 55f8ee1a07SAndrzej Bialecki 56a4cc7068SAndrzej Bialecki-v 57a4cc7068SAndrzej BialeckiRun the server verbose. Show the program options that will be used for this 58a4cc7068SAndrzej Bialeckiprocess. Will only show information during startup, no messages will 59a4cc7068SAndrzej Bialeckibe displayed while serving requests. In other words you can still 60a4cc7068SAndrzej Bialeckidaemonize without fear of output on stdout. 61f8ee1a07SAndrzej Bialecki 62a4cc7068SAndrzej Bialecki-D 63a4cc7068SAndrzej BialeckiDo not daemonize. The server will not run in the background. It will 64*b07e9f3fSUlrich Spörleinstay attached to the tty. This is useful for debugging. In this 65a4cc7068SAndrzej Bialeckimode no log file is created. Logging info is to stdout. 66a4cc7068SAndrzej Bialecki 67a4cc7068SAndrzej BialeckiThis option is automatically selected if fetch option is selected. 68a4cc7068SAndrzej Bialecki 69a4cc7068SAndrzej Bialecki-d directory 70a4cc7068SAndrzej BialeckiThe html document directory, if nothing is provided the default is 71a4cc7068SAndrzej Bialecki/httphome if UID is root, otherwise document root is ${HOME}/public_html 72a4cc7068SAndrzej Bialecki 73a4cc7068SAndrzej Bialecki-l logfile 74a4cc7068SAndrzej BialeckiSet the logfile to use. Log messages will be written to /var/log/jhttpd.log 75a4cc7068SAndrzej Bialeckiif you are root and ${HOME}/jhttpd.log otherwise. If you don't want a 76a4cc7068SAndrzej Bialeckilog file try "-l /dev/null" 77a4cc7068SAndrzej Bialecki 78a4cc7068SAndrzej Bialecki-p port 79a4cc7068SAndrzej BialeckiSet the port httpd server will listen to. Default is port 80 if 80a4cc7068SAndrzej Bialeckiyou are root and 1080 if you are not. 81a4cc7068SAndrzej Bialecki 82a4cc7068SAndrzej Bialecki-f filename 83a4cc7068SAndrzej BialeckiThis is the only option needed to use the "fetch" feature. The file 84a4cc7068SAndrzej Bialeckispecified will be the ONLY file served to ANY GET request from a browser 85a4cc7068SAndrzej Bialeckior fetch(1). 86a4cc7068SAndrzej Bialecki 87a4cc7068SAndrzej BialeckiExample 88a4cc7068SAndrzej Bialecki======= 89a4cc7068SAndrzej Bialecki 90a4cc7068SAndrzej BialeckiStandard Mode: 91a4cc7068SAndrzej Bialecki-------------- 92a4cc7068SAndrzej BialeckiIf you have the FreeBSD handbook installed on your machine and would 93a4cc7068SAndrzej Bialeckilike to serve it up over http for a quick look you could do this 94a4cc7068SAndrzej Bialecki 95a4cc7068SAndrzej Bialeckisimple_httpd -d /usr/share/doc/handbook -l /usr/tmp/jlog.txt -p 1088 -v 96a4cc7068SAndrzej Bialecki 97a4cc7068SAndrzej BialeckiAny browser would be able to look at the handbook with 98a4cc7068SAndrzej Bialeckihttp://whatever_host/handbook.html:1088 99a4cc7068SAndrzej Bialecki 100a4cc7068SAndrzej BialeckiI'm using 1088 as the port since I already have apache running on port 80 101a4cc7068SAndrzej Bialeckiand port 1080 on my host. 102a4cc7068SAndrzej Bialecki 103a4cc7068SAndrzej BialeckiPlease note, the handbook is not installed by default in FreeBSD 3.x 104a4cc7068SAndrzej BialeckiIt must be installed from the ports collection first if you want to 105a4cc7068SAndrzej Bialeckitry this. 106a4cc7068SAndrzej Bialecki 107a4cc7068SAndrzej BialeckiAnother simple example is to browse your local ports collection: 108a4cc7068SAndrzej Bialecki 109a4cc7068SAndrzej Bialeckicd /usr/ports 110a4cc7068SAndrzej Bialeckimake readmes #wait about 1 hour! 111a4cc7068SAndrzej Bialeckisimple_httpd -p 1080 -v -d /usr/ports 112a4cc7068SAndrzej Bialecki 113a4cc7068SAndrzej BialeckiThen point your browser at http://whatever_host/README.html 114a4cc7068SAndrzej Bialecki 115a4cc7068SAndrzej BialeckiFetch Mode: 116a4cc7068SAndrzej Bialecki-------------- 117a4cc7068SAndrzej BialeckiThis is designed to be used in conjunction with fetch(3). It allows 118a4cc7068SAndrzej Bialeckifor easy transfer of files from one host to another without messy 119a4cc7068SAndrzej Bialeckiauthentication or pathnames required with ftp. The file to be 120a4cc7068SAndrzej Bialeckiserved up must be readable by the user running simple_httpd. 121a4cc7068SAndrzej BialeckiThis is not a magic way to avoid permissions and read files. 122a4cc7068SAndrzej Bialecki 123a4cc7068SAndrzej BialeckiThe daemon will only serve up ONE file. The file specified will 124a4cc7068SAndrzej Bialeckibe returned for every GET request regardless of what the browser 125a4cc7068SAndrzej Bialeckiasks for. This allows for on the fly naming. 126a4cc7068SAndrzej Bialecki 127a4cc7068SAndrzej Bialeckisender# simple_httpd -f /usr/tmp/big_file.tgz 128a4cc7068SAndrzej Bialeckireceiver# fetch http://sender.com/Industrial_Secrets.tgz 129a4cc7068SAndrzej Bialecki 130a4cc7068SAndrzej Bialeckibig_file.tgz was transferred from one machine to another and renamed 131a4cc7068SAndrzej BialeckiIndustrial_Secrets.tgz at the same time. 132a4cc7068SAndrzej Bialecki 133a4cc7068SAndrzej BialeckiTunneling over other TCP ports. Choose something that firewall 134a4cc7068SAndrzej Bialeckiwill probably pass. See /etc/services. 135a4cc7068SAndrzej Bialecki 136a4cc7068SAndrzej Bialeckisender# simple_httpd -p 53 -f /usr/tmp/big_file.tgz 137a4cc7068SAndrzej Bialeckireceiver# fetch http://sender.com:53/Industrial_Secrets.tgz 138a4cc7068SAndrzej Bialecki 139a4cc7068SAndrzej BialeckiTo Do 140a4cc7068SAndrzej Bialecki===== 141a4cc7068SAndrzej Bialecki 142*b07e9f3fSUlrich SpörleinSimple authentication would be very useful [understatment]. 143a4cc7068SAndrzej Bialecki/etc/passwd or PAM would be nice. 144a4cc7068SAndrzej Bialecki 145a4cc7068SAndrzej BialeckiI think a netmask option would be good. Most internet appliances 146a4cc7068SAndrzej Bialeckiprobably want to restrict traffic to local ethernet anyway. 147a4cc7068SAndrzej Bialeckiie: Allow anything from my class C. 148a4cc7068SAndrzej Bialecki 149a4cc7068SAndrzej BialeckiThe server always has 1 zombie process hanging around when it 150a4cc7068SAndrzej Bialeckiruns as a daemon. Should fix so that it doesn't happen. 151a4cc7068SAndrzej Bialecki 152a4cc7068SAndrzej BialeckiAnything to make it faster! 153a4cc7068SAndrzej Bialecki 154a4cc7068SAndrzej BialeckiMan page 155a4cc7068SAndrzej Bialecki 156a4cc7068SAndrzej BialeckiIf anyone has any improvements or ways to easily implement something 157a4cc7068SAndrzej Bialeckiplease let me <[email protected]> know. If you make some neat embedded 158a4cc7068SAndrzej Bialeckidevice with PicoBSD I want to know too! 159f8ee1a07SAndrzej Bialecki 160f8ee1a07SAndrzej BialeckiCredits 161f8ee1a07SAndrzej Bialecki======= 162f8ee1a07SAndrzej Bialecki 163a4cc7068SAndrzej BialeckiThis program was originally contributed by Marc Nicholas <[email protected]> 164f8ee1a07SAndrzej Bialecki 165a4cc7068SAndrzej BialeckiMajor rewrite by William Lloyd <[email protected]> 166a4cc7068SAndrzej Bialecki 16797d92980SPeter Wemm$FreeBSD$ 168