Logging protcol protocol in nginx?

I was surprised to find that I could not find any information about the logging of the request protocol in the nginx access log. I usually use a server block for HTTP (80) and HTTPS (443) traffic and use a combined access log for both. I would like to indicate on each line in the access log if the request was over HTTP or HTTPS.

Is this possible, or do I need to use a separate server block for HTTPS and specify a separate access protocol for SSL?

+5
source share
2 answers

It is a little hidden in the docs, but you can use any of the common variables. This includes $scheme.

+11
source

You can combine server blocks, for example:

server {
    listen 80;
    listen 443 default_server ssl;

    # other directives
}

> nginx http/https config docs

"log_format" .

> nginx access_log docs

-1

All Articles