How to customize Nginx logs to identify mTLS client connections?

This article applies to all MetaDefender Core v5 releases deployed on Windows and Linux systems.

Currently, MetaDefender Core does not support editing the existing log format. However, it supports creating a new custom log format where Nginx can write the needed details.

Follow the steps below to generate a new log file that lets you differentiate between mTLS and regular requests:

  1. Create the configuration files:

    • Windows:

      • C:\Program Files\OPSWAT\MetaDefender Core\nginx*newlog.conf* (to configure the new log format)
      • C:\Program Files\OPSWAT\MetaDefender Core\nginx*built-in/mtls.conf* (to configure where nginx will write the log to)
    • Linux:

      • /etc/ometascan/nginx.d/newlog.conf (to configure the new log format)
      • /etc/ometascan/nginx.d/built-in/​​​​​​​mtls.conf (to configure where nginx will write the log to)
  2. Add the following data to the config files:

newlog.conf:

HTML
Copy

mtls.conf

HTML
Copy
  1. Restart the MetaDefender Core service
  2. Verify the new configuration by sending requests
    • Perform a scan request with mTLS and without mTLS.
    • The result will be as follows:

With mTLS:

HTML
Copy

Without mTLS:

HTML
Copy
  • The logging for the endpoints /file/sync, /file/batch, ^/(file|process) will no longer output to the official nginx.log in MetaDefender Core. Instead, logs will be written to the new log file.
  • It is advised to place the new log file (nginx_mtls.log) in the same folder as nginx.log.
    • This ensures it will be included in the support package.
    • The log filename must start with nginx (e.g., nginx_mtls.log).
  • This is a workaround, not an official solution. OPSWAT does not provide product support for this customization.
  • You will need to maintain the settings manually after upgrades.
  • Log rotation is not supported for the new log file.
    • The file will continuously grow in size.
    • You must implement your own rotation/cleanup process if needed.

If Further Assistance is required, please proceed to log a support case or chat with one of our support engineers.

Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard