nginx has the $scheme
variable usable in its log_format
lines.
%H
is the request protocol (e.g. "HTTP/1.1").
How can I do the same with Apache?
nginx has the $scheme
variable usable in its log_format
lines.
%H
is the request protocol (e.g. "HTTP/1.1").
How can I do the same with Apache?
This works for me with Apache 2.4.23:
%{varname}x
is only available when mod_ssl is loaded, see: https://httpd.apache.org/docs/trunk/mod/mod_ssl.html#logformatsOne way to do it is to have two conditional
CustomLog
directives, controlled by whether theHTTPS
variable is set.I have also tried using
SetEnvIf
in the following manner, but it doesn't work (it logs-
):For some reason I could not get the examples above to work, so found another way: you can add 2 rewrite rules into your configuration as follows:
Then add this into your LogFormat definition.
As the url scheme is not directly available in apache log format, you may log the canonical port (e.g. 80/443) of the server serving the request by using %p as an alternative:
Define your log output and add %H to it. This is the same for Apache.
So, you build a
LogFormat
like this and afaik there are a couple defined in the default apache configuration.and add the name of the LogFormat (in this case "common") to the end of your logfile call
Just look here for further informations about the log and here about the different format strings.