One of the challenges I’ve had in working with UnCommon Web (UCW) as an application server behind an Apache front-end is handling connection information. Modproxy creates a new connection to the app server itself, losing some of the incoming information. One way to pass that “extra” info to the app server is using an apache configuration line like this:
RequestHeader add "X-Name" "value"
This appends the new key/value pair to the HTTP headers. In my case, I wanted to tell if the connection was using SSL or not. In VirtualHost directive for the SSL listener, I added a line saying that the protocol is ‘https’.
<VirtualHost 126.96.36.199:443> SSLEngine on RequestHeader add "X-Protocol" "https"
In the non-ssl version, I put in a line saying the protocol was http.
<VirtualHost 188.8.131.52:80> RequestHeader add "X-Protocol" "http"
With the apache configuration done, apache can be restarted. Catching the value is as simple as querying the http headers in the application. Once possible way to do that in UCW is something like this
(defun protocol (req) (let ((prot (assoc "X-Protocol" (headers (it.bese.ucw.core::headers req)) :test #'string=))) (when prot (cdr prot))))