146493SabialSimple_httpd - A small and free Web server 238589Sabial 346493Sabial"Simple_httpd is like /usr/bin/mail is to mail clients, no frills." 446493Sabial 546493SabialThis HTTP server can be used in any FreeBSD/PicoBSD application. 646493Sabial 746493SabialIt has been tested under FreeBSD 2.2.x, 3.x and 4.x. It might work 846493Sabialon other OS systems, but it's for FreeBSD primarily. 946493Sabial 1046493SabialThe main advantage to Simple_httpd is that it is very small. 1146493SabialThe 25K binary can satisfy most needs in a small or embedded 1246493Sabialappplication. If you want a full featured server see 1346493Sabial/usr/ports/www/apache* or http://www.apache.org 1446493Sabial 1546493SabialSimple_httpd is released under a BSD style copyright that unlike 1646493SabialGPL is embedded developer friendly. 1746493Sabial 1846493SabialThe server is designed to be run in one of two modes. The standard 1946493Sabialmode is a httpd server running in the background serving up a directory 2046493Sabialof html,gif,cgi whatever. Your traditional www server. 2146493Sabial 2246493SabialThe "fetch" mode supports file transfer over httpd. This 2346493Sabialis best thought of as mate for fetch(1). This feature can be 24229779Suqsuseful to transfer a file from one host to another. 2546493Sabial 2646493SabialSimple_httpd has the ability to run CGI scripts. All CGI 2746493Sabialscripts must be located in ${DOCUMENT_ROOT}/cgi-bin. The 28229779Suqsserver currently only sets 3 environment variables before calling 2946493Sabialthe script. 3046493Sabial 31229779SuqsCGI Environment variables are below: 3246493Sabial 3346493SabialSERVER_SOFTWARE = FreeBSD/PicoBSD 3446493SabialREMOTE_HOST = client.canada_lower_taxes.com 3546493SabialREMOTE_ADDR = 200.122.13.108 3646493Sabial 3746493SabialIn most target applications for this server the extra DNS traffic from 3846493Sabialthe remote_addr lookup will likely be on the local lan anyway and not 3946493Sabialon the other side of the internet. You can turn it off yourself in 4046493Sabialthe code if you want to speed the whole process up. Be sure to turn 4146493Sabialit off for the logfile also. 4246493Sabial 4343939SabialHow to use it? 4443939Sabial============== 4538589Sabial 4646493SabialCompile with make, run as follows 4743939Sabial 4846493Sabialusage: simple_httpd [-vD] 4946493Sabial [-d directory] 5046493Sabial [-g grpid] 5146493Sabial [-l logfile] 5246493Sabial [-p port] 5346493Sabialor 5446493Sabialusage: simple_httpd [-p port] -f filename 5543939Sabial 5646493Sabial-v 5746493SabialRun the server verbose. Show the program options that will be used for this 5846493Sabialprocess. Will only show information during startup, no messages will 5946493Sabialbe displayed while serving requests. In other words you can still 6046493Sabialdaemonize without fear of output on stdout. 6143939Sabial 6246493Sabial-D 6346493SabialDo not daemonize. The server will not run in the background. It will 64229779Suqsstay attached to the tty. This is useful for debugging. In this 6546493Sabialmode no log file is created. Logging info is to stdout. 6643939Sabial 6746493SabialThis option is automatically selected if fetch option is selected. 6846493Sabial 6946493Sabial-d directory 7046493SabialThe html document directory, if nothing is provided the default is 7146493Sabial/httphome if UID is root, otherwise document root is ${HOME}/public_html 7246493Sabial 7346493Sabial-l logfile 7446493SabialSet the logfile to use. Log messages will be written to /var/log/jhttpd.log 7546493Sabialif you are root and ${HOME}/jhttpd.log otherwise. If you don't want a 7646493Sabiallog file try "-l /dev/null" 7746493Sabial 7846493Sabial-p port 7946493SabialSet the port httpd server will listen to. Default is port 80 if 8046493Sabialyou are root and 1080 if you are not. 8146493Sabial 8246493Sabial-f filename 8346493SabialThis is the only option needed to use the "fetch" feature. The file 8446493Sabialspecified will be the ONLY file served to ANY GET request from a browser 8546493Sabialor fetch(1). 8646493Sabial 8746493SabialExample 8846493Sabial======= 8946493Sabial 9046493SabialStandard Mode: 9146493Sabial-------------- 9246493SabialIf you have the FreeBSD handbook installed on your machine and would 9346493Sabiallike to serve it up over http for a quick look you could do this 9446493Sabial 9546493Sabialsimple_httpd -d /usr/share/doc/handbook -l /usr/tmp/jlog.txt -p 1088 -v 9646493Sabial 9746493SabialAny browser would be able to look at the handbook with 9846493Sabialhttp://whatever_host/handbook.html:1088 9946493Sabial 10046493SabialI'm using 1088 as the port since I already have apache running on port 80 10146493Sabialand port 1080 on my host. 10246493Sabial 10346493SabialPlease note, the handbook is not installed by default in FreeBSD 3.x 10446493SabialIt must be installed from the ports collection first if you want to 10546493Sabialtry this. 10646493Sabial 10746493SabialAnother simple example is to browse your local ports collection: 10846493Sabial 10946493Sabialcd /usr/ports 11046493Sabialmake readmes #wait about 1 hour! 11146493Sabialsimple_httpd -p 1080 -v -d /usr/ports 11246493Sabial 11346493SabialThen point your browser at http://whatever_host/README.html 11446493Sabial 11546493SabialFetch Mode: 11646493Sabial-------------- 11746493SabialThis is designed to be used in conjunction with fetch(3). It allows 11846493Sabialfor easy transfer of files from one host to another without messy 11946493Sabialauthentication or pathnames required with ftp. The file to be 12046493Sabialserved up must be readable by the user running simple_httpd. 12146493SabialThis is not a magic way to avoid permissions and read files. 12246493Sabial 12346493SabialThe daemon will only serve up ONE file. The file specified will 12446493Sabialbe returned for every GET request regardless of what the browser 12546493Sabialasks for. This allows for on the fly naming. 12646493Sabial 12746493Sabialsender# simple_httpd -f /usr/tmp/big_file.tgz 12846493Sabialreceiver# fetch http://sender.com/Industrial_Secrets.tgz 12946493Sabial 13046493Sabialbig_file.tgz was transferred from one machine to another and renamed 13146493SabialIndustrial_Secrets.tgz at the same time. 13246493Sabial 13346493SabialTunneling over other TCP ports. Choose something that firewall 13446493Sabialwill probably pass. See /etc/services. 13546493Sabial 13646493Sabialsender# simple_httpd -p 53 -f /usr/tmp/big_file.tgz 13746493Sabialreceiver# fetch http://sender.com:53/Industrial_Secrets.tgz 13846493Sabial 13946493SabialTo Do 14046493Sabial===== 14146493Sabial 142229779SuqsSimple authentication would be very useful [understatment]. 14346493Sabial/etc/passwd or PAM would be nice. 14446493Sabial 14546493SabialI think a netmask option would be good. Most internet appliances 14646493Sabialprobably want to restrict traffic to local ethernet anyway. 14746493Sabialie: Allow anything from my class C. 14846493Sabial 14946493SabialThe server always has 1 zombie process hanging around when it 15046493Sabialruns as a daemon. Should fix so that it doesn't happen. 15146493Sabial 15246493SabialAnything to make it faster! 15346493Sabial 15446493SabialMan page 15546493Sabial 15646493SabialIf anyone has any improvements or ways to easily implement something 15746493Sabialplease let me <wlloyd@slap.net> know. If you make some neat embedded 15846493Sabialdevice with PicoBSD I want to know too! 15946493Sabial 16043939SabialCredits 16143939Sabial======= 16243939Sabial 16346493SabialThis program was originally contributed by Marc Nicholas <marc@netstor.com> 16443939Sabial 16546493SabialMajor rewrite by William Lloyd <wlloyd@slap.net> 16646493Sabial 16750479Speter$FreeBSD$ 168