2.3 Using JOH in CGI Mode

The ‘CGI’ mode is a bit more complicated, because it involves configuring two components. However, the default settings are chosen so as to simplify the configuration. First, select the socket to use for interprocess communication between johd and joh.cgi. If both processes run on the same box, then ‘localhost’ or some UNIX socket is a natural choice. Now, start the daemon:

 
johd -l 127.0.0.1

Make sure the socket 127.0.0.1:1100 is accessible from localhost. In particular, if your ‘/etc/hosts.deny’ contains the line ‘ALL: ALL’, place this in your ‘/etc/hosts.allow’:

 
johd: 127.0.0.1

Similarly, make sure outgoing connections to selected Jabber servers are allowed for localhost:

 
johd/jabber@213.130.31.41: 127.0.0.1

Then copy joh.cgi to your ‘cgi-bin’ directory and you're done. You might also wish to configure your HTTP server to use some good-looking alias for that. For example, in my Apache configuration I use:

 
Alias /http-poll  /var/www/cgi-bin/joh.cgi

If your HTTP server and johd are running on different machines, you will need to inform joh.cgi about the address johd is listening on. Suppose, for example, that johd is running on machine ‘A’ and is listening on IP address 192.168.0.1, port 1100. The HTTP server is running on the machine ‘B’, which has IP address 192.168.0.2. To tell joh.cgi it must connect to ‘192.168.0.1:1100’, set the environment variable JOH_SERVER_URL. For example, if ‘B’ is running Apache, then in your ‘httpd.conf’ you would set:

 
SetEnv JOH_SERVER_URL 192.168.0.1:1100

Notice also, that you need to ensure that this socket on the box ‘A’ is accessible only to 192.168.0.2. For example:

  1. In ‘/etc/hosts.deny’:
     
    johd: ALL
    
  2. In ‘/etc/hosts.allow’:
     
    johd: 192.168.0.2