Q:

When using nginx, how can I get the $scheme using lua?

nginx provides a variable named scheme which contains either http or https. In a reverse proxy I'm writing using openresty, I want to access that variable from a content_by_lua_block. I know there are variables to get request headers (ngx.req.get_headers()) or other elements, but how can I get the request scheme ?

A:

Seems like it's just a matter of using ngx.var.VARIABLE prefix. In my case, it will be ngx.var.scheme.

