MyHTTP 1.0.0 Manual


About
MyHTTP is a lightweight web server written in C for UNIX systems. The whole program is less than 400 lines of code, and the compiled executable is usually less than 20KB. Functions include file transfer via HTTP, access logging, and configuration. No CGI support; No directory listing; It just works.

This web server is suitable for building a low consumption web server on low-end hardware. I have written some routines to prevent buffer overflow problem to avoid the overflow attack of the hackers. Potential security problems and bugs may still exist, but less code means less bugs, less problems.


System Requirement
  • An UNIX-based operating system
  • GCC installed



  • Installation
    This software package only comes with the source code, you need to compile it before you use. After decompress the archive, goto the software directory and then type "./compile.sh" to compile the source. For some systems (such as Solaris), the compilation script does not work, because you are require to add an argument to link to the socket library. So, the command will become:

    cc -Wall myhttp.c -o myhttp -lsocket

    After you successfully compile the source, an executable named "myhttp" will be produced. Type "./myhttp &" to run it in the background.


    Configuration
    The file "myhttp.conf" is the main configuration file. The details of the values are listed in the following table:

    Value
    Description
    Port The port used for the web server. The default value is 80.
    MaxConn This is the "backlog" parameter of listen() function. Please see the man page of listen() for details.
    ConnTimeout Connection timeout. Disconnect the client if no response after n seconds.
    BufferSize The size (in bytes) of the buffer for sending file. Do not set this value too large on a slow network connection.
    Logging Enable(1)/Disable(0) access logging. The log file "myhttp.log" located at the same directory of the web server.
    PublicDIR The directory used for access the file. Do not put a slash at the end of the path.
    IndexName The default page of a directory.
    DefaultMIME If the file suffix was not found in the mime.conf. Use this MIME string.

    If you are not clear what these things are, do not modify this file and use the default values.

    Another configuration file "mime.conf" stores a list of MIME string and file suffix. MIME string is used for specify the type of a file according to the file suffix. This string will send through the HTTP header. In fact, most web browsers can handle the file type properly without this string. But for compatibility reasons, add the appropriate file suffix and MIME string according to your needs.



    --- End of the manual ---