Configuring Apache HTTP Server

About Apache HTTP Server

Flash Media Server includes Apache HTTP Server. If you install and enable the web server, you can deliver client SWF files, container HTML pages, and media assets from Flash Media Server. You can serve content over HTTP, as well as RTMP. In addition, you can serve video over HTTP progressive download as a fallback solution for web proxies that break RTMP or RTMPT.

The Flash Media Server installation of Apache is like the standard installation. You can use Apache documentation for most configuration tasks. The Apache root installation folder is rootinstall/Apache2.2. The web root is rootinstall/webroot.

Note: The Flash Media Server documentation uses “rootinstall” to indicate the Flash Media Server root installation folder (C:\Program Files\Adobe\Flash Media Server 4 by default on Windows). The Apache documentation and configuration files use “ServerRoot” to indicate the Apache root installation folder.

Installation locations

The Apache server that installs with Flash Media Server differs from a standard Apache installation in the following ways:

  • The apachectl files are in the rootinstall/Apache2.2/manual/programs folder.

  • The httpd.conf file and the standard secondary configuration files are in the rootinstall/Apache2.2/conf folder.

  • The log files are in the rootinstall/Apache2.2/logs folder. For more information, see Monitoring and Managing Log Files.

Alternate configurations

To do any of the following, edit the rootinstall/Apache2.2/conf/httpd.conf file:

  • Handle multiple adaptors or virtual hosts

  • Block sensitive file types, such as ASC

  • Handle any non-standard MIME types required for progressive download

  • Serve the default server-status and server-info pages

  • Modify source directories

Specify the maximum HTTP header line length

In the Flash Media Server Adaptor.xml file, the MaxHeaderLineLength element determines the size of the HTTP header the server can handle. The default value for MaxHeaderLineLength is 1024 bytes. Some browsers send a header larger than 1024 bytes. In this scenario, Apache sends back an empty response. To fix this issue, configure MaxHeaderLineLength to 8192.

Note: By default, the Apache HTTP header size limit is 8 KB (8190 bytes plus a carriage return).
  1. Open rootinstall/conf/Adaptor.xml in a text editor.

  2. Edit the following line:

    <MaxHeaderLineLength>8192</MaxHeaderLineLength>
  3. Save the file.

  4. Restart the server.

Enable and disable Apache and HTTP proxying

When you install Flash Media Server and choose to install Apache, it is enabled by default. Flash Media Server listens on port 80 and proxies HTTP requests to Apache over port 8134.

Setting the parameter to no value disables HTTP proxying:

HTTPPROXY.HOST =

To proxy to a remote server, set the parameter to the remote server you want to use:

HTTPPROXY.HOST = webfarm.example.com:80

Enable Apache and HTTP proxying

  1. Open the fms.ini file in a text editor.

  2. Add port 80 to the ADAPTOR.HOSTPORT tag.

    ADAPTOR.HOSTPORT = :1935, 80

  3. To start and stop Apache when Flash Media Server starts and stops, set the SERVER.HTTPD_ENABLED parameter to true:

    SERVER.HTTPD_ENABLED = true
  4. Do one of the following:

    • Open rootinstall/conf/fms.ini and set the value of the HTTPPROXY.HOST variable to 8134:

      HTTPPROXY.HOST = :8134
    • Open the Adaptor.xml configuration file in a text editor.

      If you have multiple adaptors, open the file for the adaptor you want to configure. The default Adaptor.xml file is located in the rootinstall\conf\_defaultRoot_ folder.

      Set the enable attribute of the HttpProxy tag to "true", as in the following:

      <HttpProxy enable="true" maxbuf="16384"> 
          <Host port="80">${HTTPPROXY.HOST}</Host> 
      </HttpProxy>

      Save and validate the Adaptor.xml file.

  5. Restart the server.

Disable Apache and HTTP proxying

  1. Open the fms.ini file in a text editor.

  2. Remove port 80 from the ADAPTOR.HOSTPORT tag.

    ADAPTOR.HOSTPORT = :1935

  3. Do one of the following:

    • Open rootinstall/conf/fms.ini and set the value of the HTTPPROXY.HOST variable to no value:

      HTTPPROXY.HOST = 
    • Open the Adaptor.xml configuration file in a text editor.

      If you have multiple adaptors, open the file for the adaptor you want to configure. The default Adaptor.xml file is located in the rootinstall\conf\_defaultRoot_ folder.

      Set the enable attribute of the HttpProxy tag to "false", as in the following:

      <HttpProxy enable="false" maxbuf="16384"> 
          <Host port="80">${HTTPPROXY.HOST}</Host> 
      </HttpProxy>

      Save and validate the Adaptor.xml file.

  4. Restart the server.

Deliver SWF files and HTML files over HTTP

Apache can deliver SWF files, HTML files, JPG files, and many other standard file types over HTTP. Place files that you want to deliver over HTTP in the correct folders. By default, Apache is configured to use following paths:

Path

Location

Example URL

/

rootinstall/Apache2.2/webroot

http://myFMSServer.com/app.swf

/cgi-bin

rootinstall/Apache2.2/cgi-bin

http://myFMSServer.com/cgi-bin/someScript.pl

These folders are global, not application-specific. Any SWF files and HTML files you want to serve over HTTP must be in these folders or in application-specific folders. To create aliases for application-specific folders, edit the httpd.conf file.

Create web directories for applications

To have Apache serve content over HTTP, either use one of the predefined web directories or create a web directory for that application. To create a web directory for an application, add an alias to the rootinstall/Apache2.2/conf/httpd.conf file. For example, the following lines create an alias that points to the streams directory of an application called “hd”:

Alias /hd/ "applications/hd/streams/_definst_/" 
<Directory "applications/hd/streams/_definst_/"> 
    Options Indexes MultiViews FollowSymLinks 
    AllowOverride None 
    Order allow,deny 
    Allow from all 
</Directory>

Copy media files to the rootinstall/applications/hd/streams/_definst_/ folder to serve them over HTTP. For example, if a client requests http://fms.example.com/hd/someVideo.flv, Apache serves it the someVideo.flv file from the rootinstall/applications/hd/streams/_definst_/ folder.

For more information about editing the configuration file, see the Apache documentation at www.apache.org.

Using Apache as a WebDAV host

You can configure the web server to act as a WebDAV host. For information, see the Apache HTTP Server version 2.2.15 documentation at www.apache.org.

The following keywords are reserved words: open, close, send, idle, fcs, fms, crossdomain.xml, fpad. Reserved words cannot be used for directory names under the webroot directory or for anything else. If you have applications with these names, use custom aliases to give the HTTP virtual directories slightly different names from the RTMP applications, such as “open_”.

Running Apache for Windows as a service

To install Apache to run as a service on Windows:

  1. Open a Command prompt.

  2. Change directories to the rootinstall/Apache2.2/bin folder. For example, at the command prompt, enter the following:
    cd ../../Program Files/Adobe/Flash Media Server 4/Apache2.2/bin
  3. To install Apache to run as a service, enter the following:

    httpd.exe -f conf/httpd.conf -n FMSHttpd -k install
    Note: To uninstall Apache, enter the following: httpd.exe -n FMSHttpd -k uninstall.
  4. To verify that Apache is running, open the Windows Services panel and locate the FMSHttpd service.

To start and stop the Windows services on Windows XP:
  1. Right click My Computer and select Manage. The Computer Management dialog box displays.

  2. Select Services and Applications.

  3. Double-click Services. The list of available services displays.

  4. To start a service, select the service from the list and click the Start Service button. To stop a service, select the service from the list and click the Stop Service button.

Upgrading Apache HTTP server

At some time after installing Flash Media Server, you might be required to update the included Apache web server. Most commonly, this would be due to Apache HTTP server security patches or functionality upgrades.

The version of the Apache HTTP server that ships with Flash Media Server 4.5 is 2.2.17. For the latest information about the Apache web server, see httpd.apache.org.

The recommended approach to upgrading the Apache web server is to install or build the Apache server in a directory that is separate from the existing server. Then copy the contents of newly-installed directories to the existing server.

In most cases, you do not replace the existing Apache configuration files with the newer versions of these files. This is because the Apache web server installation for Flash Media Server is pre-configured with specific modules and settings. If there are changes to the configuration files, it is usually easier to update the existing files with changes.

Before upgrading:
  1. Review any installation notes on apache.org about the differences between the current version and the new version. For example, look for renamed directives or renamed modules that would require you to merge configuration files.

  2. Make sure the currently-installed version of Apache is working correctly:
    1. Check the master log file for errors. The master.00.log file should have a line that launches the httpd process and returns 0; for example:
      - C:\Program Files\Adobe\Flash Media Server 4\Apache2.2\bin\httpd 
      -f ./conf/httpd.conf -d "C:\Program Files\Adobe\Flash Media Server 4\Apache2.2" 
      -n FMSHttpd -k start returned 0:
    2. Try playing videos using the “http” protocol.

  3. Check the current version of Apache and make a note of it. From a command prompt, go to FMS_Install_Dir/Apache2.2/bin and issue the following command:
    httpd -v
  4. Back up following directories:
    FMS_Install_Dir/Apache2.2/bin  
    FMS_Install_Dir/Apache2.2/lib  
    FMS_Install_Dir/Apache2.2/include  
    FMS_Install_Dir/Apache2.2/modules  
    FMS_Install_Dir/Apache2.2/manual  
    FMS_Install_Dir/Apache2.2/icons
To upgrade:
  1. Stop Flash Media Server.

  2. Follow the directions on apache.org to download and run the Apache installer. If you are using Linux, you may be required to build the Apache server on your system.

  3. Copy the following directories from the newly-installed version to the current version that was installed with Flash Media Server:
    Apache_Install_Dir/bin  
    Apache_Install_Dir/modules  
    Apache_Install_Dir/manual  
    Apache_Install_Dir/icons

    Note that the /conf directory, which contains the Apache configuration files, is not included in this list. You should not replace the existing configuration files with the new configuration files.

  4. Merge the configuration files, if necessary. In most cases, you will not need to merge the files. However, if the newer version of Apache includes new or renamed modules or directives, you might need to edit the configuration files to meet the new requirements.

  5. Start Flash Media Server.

After upgrading:
  1. Ensure that the newer version of Apache is now available. From a command prompt, go to FMS_Install_Dir/Apache2.2/bin and issue the following command:
    httpd -v
  2. Recompile third-party modules, if necessary.

  3. Make sure the newly-updated version of Apache is working correctly:
    1. Check the master log file for errors or warnings. The master.00.log file should have a line that launches the httpd process and returns 0; for example:
      - C:\Program Files\Adobe\Flash Media Server 4\Apache2.2\bin\httpd -f 
      ./conf/httpd.conf -d "C:\Program Files\Adobe\Flash Media Server 4\Apache2.2" -n FMSHttpd -k start returned 0:
    2. Try playing videos using the “http” protocol.

Troubleshooting Apache HTTP server

In some cases, the Apache server could be at fault for the Flash Media Server not running properly. This is sometimes caused by syntax errors in the Apache configuration files.

Check the master.log file in the rootinstall/logs directory. If Apache could not start for some reason, it typically returns an error code of “1” and writes a line similar to the following in the master.log file:
2010-06-22 15:45:09 4276 (w)2581414 C:\Program Files\Adobe\Flash Media Server 4 
\Apache2.2\bin\httpd -f ./conf/httpd.conf -d "C:\Program Files\Adobe\Flash Media Server 4 
\Apache2.2" -n FMSHttpd -k start returned 1: 

The status of (w) or (e) indicates a warning or error. For more information about status codes in the master.log file, see Diagnostic logs.

If you are running Flash Media Server as a service, you can check the Windows Event Viewer for errors messages. On Linux, check syslog’s log file for error messages.

You can also check the Apache log files for error messages. The default location of the Apache log files is rootinstall/Apache2.2/logs. The logs are in the default Apache error and combined access log formats. For information about these log file formats, see Log Files.

To change the location of the log files, edit the rootinstall/Apache2.2/conf/httpd.conf file.