The Apache HTTP Server (httpd) supports dynamic content via external executables called CGI programs.
Probably the best way to integrate Synchronet behind Apache is to configure MOD_PROXY on Apache to reverse-proxy calls for .ssjs files to Synchronet's HTTP server running on a different port. It's worth noting that the current SBBS web interface is setup to use HTTP Authentication, and would need to be adjusted to support a cookie based authentication scheme. By configuring Apache to use the same directory as SBBS, you can rely on Apache to perform caching and compression of non-dynamic content to be delivered directly.
Roughneck BBS is currently using a custom reverse proxy for use with IIS. You may email the sysop for a copy.
The easiest way to get dynamic Synchronet content (e.g. users, messages, files) served by the Apache HTTP Server is by using JSexec as a CGI program to execute JavaScript (e.g. .js
or .ssjs
) files that generate dynamic HTML (on stdout
).
JavaScript code that generates dynamic CGI content must first send one or more headers, followed by a blank-line, followed by the actual content (e.g. HTML).
As an example, the following generates a very basic one-line header (declaring the content to be plain-text), followed by a blank line, followed by one line of text (the ubiquitous Hello, World!
):
print("Content-Type: text/plain"); print(); print("Hello, world!");
If the content is going to contain HTML, then you would want to declare the Content-Type
to be text/html
instead.
For example, to execute the exec/nodelist-html.js
script to display to a web client a dynamically-generated BBS node list in HTML, create a file named nodelist
in your Apache content cgi-bin
directory containing the following 2 lines:
#!/bin/sh exec /sbbs/exec/jsexec -c/sbbs/ctrl nodelist-html.js
Don't forget to make the file executable: chmod a+x nodelist
Now when a web client requests the URL http://yourbbs.com/cgi-bin/nodelist
from your Apache HTTP Server, they'll get the dynamic Synchronet node-list in HTML.
Another option is to embed the JavaScript code in the CGI executable file itself. As an example, creating the file cgi-bin/test.cgi
containing the following 4 lines:
#!/usr/sbin/jsexec -c/sbbs/ctrl print("Content-Type: text/plain"); print(); print("Hello, world!");
Don't forget to make the file executable: chmod a+x test.cgi
Now when a web client requests the URL http://yourbbs.com/cgi-bin/test.cgi
from your Apache HTTP Server, they'll get the “Hello, world!” message.