2.5 HTTP GET Requests

Proxying of Jabber connections is requested by HTTP requests with either ‘POST’ or ‘CONNECT’ methods. Any other requests received by johd are normally dropped. However, ‘GET’ requests are handled separately. Normally, an incoming ‘GET’ request means that someone has pointed his web browser to the URL served by johd. When such a request arrives, johd replies with a 404 response code. A compiled-in error page is sent back in the response. This behavior can be customized in two ways.

First, you can supply a custom error page using the ‘-E’ command line option. The argument to this option must specify an absolute pathname to a valid HTML file. The contents of this file will be sent back in 404 responses.

Similarly to ‘-c’ and ‘-S’ options, the ‘-E’ option applies to all HTTP sockets created by subsequent ‘-l’ options which appear to the right of it, until another ‘-E’ or ‘-R’ option (see below) is encountered.

An example usage follows:

 
johd -c HTTP -E /etc/joh/404.html -l 10.10.10.1

Another way to handle ‘GET’ requests is to return a 303 response, redirecting the requester to another HTTP resource. This is achieved via the ‘-R’ option. Its argument is a valid URL, beginning with a ‘http://’. For example:

 
johd -c HTTP -R http://www.example.net/jabber

Notice, that ‘-E’ and ‘-R’ options are mutually exclusive. For example, the following invocation will reply to ‘GET’ requests arriving to ‘10.10.10.1’ with the error page read from ‘/etc/joh/404.html’, and will redirect any ‘GET’ request arriving to ‘10.10.10.2’ to <http://www.example.net/jabber>:

 
johd -c HTTP -E /etc/joh/404.html -l 10.10.10.1 \
     -R http://www.example.net/jabber -l 10.10.10.2

The ‘joh.cgi’ utility provides similar features, except that it cannot send back a ‘404’ response.

If any request other than ‘POST’ arrives, ‘joh.cgi’ replies with the compiled-in error page, just as johd does. If the JOH_ERROR_PAGE environment variable is set, and its value points to a readable file, this file's contents is sent back instead.

If JOH_ERROR_REDIRECT variable is set and its value is a URL which begins with ‘http://’, joh.cgi responds with a redirection to that URL.