Configuring GoAhead WebServer

To change the default settings and configuration of GoAhead WebServer, you will need to modify the Makefile and main program file (main.c) for your target operating system (OS). To find out the name of the Makefile for your target OS, read your operating system's compile instructions provided in Installing GoAhead WebServer. The table below outlines the settings and configuration operations available in the current release, as well as the file you need to edit to make the change. When editing source files, set your tab stop setting to 4.

ItemDescriptionFile
Document Root DirectoryThe directory on the server in which Web documents will be stored. For example, if you define /web/doc/ as the directory, and the URL http://www.yourhost.com/myfile.htm is requested, the Web server will return the file myfile.htm located in /web/doc/ (unless the file does not exist).main.c
Default Server Home PageThe Web page that is returned when the server is accessed by its hostname (e.g., http://www.yourhost.com).main.c
Default Directory Index FileThe name of the file that will be returned by default when the URL requested is a directory path. For example, if the index file is home.htm and the URL requested is http://www.yourhost.com/directory, the server will return the file /directory/home.htm.main.c
PasswordThe password required to access your servermain.c
PortThe port that the server will run on.main.c
RetriesThe number of times the system will try a different port if the specified port is not available.main.c
Retrieve from ROMForces GoAhead WebServer to retrieve files from ROM.Makefile
Enable Access LoggingEnables logging of access to your server.Makefile
Enable Keep-AliveEnables the HTTP 1.1 Keep-Alive feature (persistent connections)Makefile
Enable If-Modified-SinceEnables the HTTP If-Modified-Since request header field.Makefile
Enable Memory Leak LoggingEnables logging of memory and stack statistics for debugging purposes. Makefile
User Management Enables enhanced password and security features.Makefile
Digest Access AuthenticationEnables the use of Digest Access Authentication.Makefile

User Management

To enable the User Management API, which provides the user and security database, set the following compiler define in the Makefile for your target operating system.

USER_MANAGEMENT_SUPPORT

The code for the user management functions reside in these files:

Um.c, um.h: User management API
Emfdb.c emfdb.h: Database routines

Digest Access Authentication

To enable the use of Digest Access Authentication, which provides encrypted password authentication, set the following compiler define in the Makefile for your target operating system:

DIGEST_ACCESS_SUPPORT

The source code files, websda.c and md5c.c, contain the digest calculation routines. The files, webs.c, webs.h and security.c contain code that is activated when this compiler switch is defined.

Document Root Directory

The GoAhead WebServer default document root directory is "web", which is created under webserver/ when GoAhead WebServer is installed and compiled. To change the directory, edit the following portion of code in the Web server's main program file (main.c).

     *rootWeb = T("web");

Change web to the new directory name.

Default Server Home Page

The GoAhead WebServer default home page is "home.asp". To change the page, edit the following portion of code in the Home page handler function located in the server's main program file (main.c):

     websRedirect(wp, T("home.asp"));

Change home.asp to the name of file you want to use as the home page and make sure to save the file in the document root directory.

Default Directory Index File

The GoAhead WebServer default directory index file is set to "default.asp". To change the file, edit the following portion of code in the Home page handler function located in the server's main program file (main.c):

     websSetDefaultPage(T("default.asp"));

Change default.asp to the file name you want to use. Note that, if a "default.asp" is not found in the directory requested by the browser, the server will return a 404 Document Not Found error.

Password

The default GoAhead WebServer password is blank. In other words, no password is required to access the server. To password-protect your server, edit the following portion of code in the Home page handler function located in the server's main program file (main.c):

     *password = T("");

Insert the password you want to use inside the quotation marks.

Port

GoAhead WebServer runs on port 80 by default. To change the server port, edit the following portion of code in the Home page handler function located in the server's main program file (main.c):

      port = 80;

Retries

By default, GoAhead WebServer retries five times to find an alternative port when the default port is not available. To change the number of retries, edit the following portion of code in the Home page handler function located in the server's main program file (main.c):

     retries = 5;

Retrieve From ROM

By default, GoAhead WebServer retrieves Web pages from a file system. To force GoAhead WebServer to retrieve Web pages from ROM, set the following compiler define in the Makefile for your target operating system.

     WEBS_PAGE_ROM

Note: This release of GoAhead GoAhead WebServer includes WebCompiler, which creates ROMable C source code for a set of Web documents. See the Readme (readme.txt) for information on using the compiler.

Enable Access Logging

To enable logging of access to your server, set the following compiler define in the Makefile of your target operating system.

     WEBS_LOG_SUPPORT

Note: The content and format of the information logged is found in a gsnprintf function call within the function websLog located in webs.c.

Enable Keep-Alive

To enable HTTP 1.1 Keep-Alive support, set the following compiler define in the Makefile for your target operating system.

     WEBS_KEEP_ALIVE_SUPPORT

The code for this feature has not been fully tested in this release so it may required some debugging.

Enable If-Modified-Since

To enable support for the HTTP If-Modified-Since request header field, set the following compiler define in the Makefile for your target operating system.

     WEBS_IF_MODIFIED_SUPPORT

Enable Memory Leak Logging

To enable the logging of memory and stack statistics for debugging purposes, set the following compiler define in the Makefile for your target operating system.

     B_STATS

If B_STATS is defined, the memLeaks function, when called, will output the balloc (basic allocation) statistics to a file called "leak.txt" in the directory from which the GoAhead WebServer executable was launched (webs). In the current release, the only call to memLeaks occurs in the main program (main.c) when the program does a normal exit. Developers can add the function to other appropriate locations to aid in the debugging process.

Additional Configuration Notes

UEMF Symbolic Constant

Make sure the symbolic constant UEMF is defined in the command line arguments to the compiler in the Makefile of the target operating system.

Windows CE and UNICODE

The symbolic constant UNICODE needs to be defined in the Makefile for Windows CE compilations or any other builds that need to use unicoded character strings.

Windows 95/98/NT

When you run GoAhead WebServer, an icon is added to your Windows Taskbar. You can set the title and name of the icon's window by modifying the following two portions of code in the main program (main.c).

     *title = T("GoAhead GoAhead WebServer");
     *name = T("gowebs");

VXWORKS

You may need to change the CC (compiler), AR (archiver) and LD (linker/loader) definitions in the VXWORKS Makefile if you are using a different BSP (Board Support Package).

You will need to change the variable ROOT_DIR in the main program (main.c) to reflect the name of the root directory for your file system.