-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
Description
Add a (debug) functionnality to log all the http headers coming to the openresty/nginx along with the http requests.
Exemple, add the setting "log_http_headers" in the mfserv config.ini
[nginx]
# If logging=0, do not log anything in nginx_access.log
# logging=1
# If log_http_headers=1, the HTTP headers are logged in nginx_access_with_http_headers.log
# default: 0 (disabled)
log_http_headers=0
We don't always have control over the hardware that's supposed to transmit the HTTP headers to us, so we need to be able to verify that we are indeed receiving the headers.
Exemple of HTTP headers we need to be sure to receive along with each request, moreover when the TLS termination is not done in our mfserv service:
- X-Forwarded-Proto (the original protocol)
- X-Forwarded-Port (the original port)
- X-SSL-Client-Cert (a client certificate)
- X-SSL-Client-Verif (the client certificate validation)
We often use the below "hack" in a plugin in order to log the http headers:
- add a nginx location in config through the "extra_server" config:
location /headers {
set $plugin "log_headers";
content_by_lua_file {{ MFSERV_CURRENT_PLUGIN_DIR }}/log_headers.lua;
}
- with lua script:
local headers = ngx.req.get_headers()
for key, value in pairs(headers) do
ngx.log(ngx.ERR, key .. ": " .. value)
end
=> call the /headers endpoint then the http headers coming to our mfserv are logged in the nginx_error.log