Information
When acting as a reverse proxy, NGINX must be configured to function as a secure TLS client. This requires validating the identity of the upstream server by verifying its certificate against a trusted Certificate Authority (CA). Furthermore, NGINX must ensure that the hostname of the upstream server matches the name (Subject Name / SAN) within the certificate itself.
Without proper validation, NGINX blindly trusts the identity of the upstream server, making it vulnerable to man-in-the-middle (MitM) attacks within the internal network. An attacker could impersonate a legitimate backend service and intercept sensitive traffic. By enforcing certificate validation ( proxy_ssl_verify ) and hostname verification ( proxy_ssl_name ), NGINX guarantees that it is communicating with the intended, authentic upstream server.
NOTE: Nessus has provided the target output to assist in reviewing the benchmark to ensure target compliance.
Solution
To securely configure upstream validation, you must obtain the CA certificate that signed your upstream server's certificate.
- Place the CA certificate (e.g., upstream_ca.crt ) in a secure directory on the NGINX server (e.g., /etc/nginx/ssl/ ).
- In the location block that proxies traffic, add the following three directives. The proxy_ssl_name must match the hostname used in the proxy_pass directive.
location /api/ {
proxy_pass https://your-upstream-hostname.com;
# 1. Enable verification
proxy_ssl_verify on;
# 2. Specify the CA to trust for verification
proxy_ssl_trusted_certificate /etc/nginx/ssl/upstream_ca.crt;
# 3. Verify the certificate's name matches the server's hostname
proxy_ssl_name your-upstream-hostname.com;
}
Impact:
Enabling strict upstream verification introduces a dependency on certificate lifecycle management. If the upstream server's certificate expires or is misconfigured, or if the CA certificate file on the NGINX server is outdated, NGINX will refuse to connect to the upstream, resulting in a service outage. This behavior is intentional and secures the connection at the cost of requiring careful certificate management.