I want to setup Nginx for SSL termination. All request with valid client certificates will be terminated at Nginx and request will be forwarded to backend app. I have following Nginx configuration
upstream app {
server app:8080;
}
server {
listen 443 ssl;
server_name localhost;
ssl_certificate /etc/ssl/cert_example_com.crt;
ssl_certificate_key /etc/ssl/cert_example_com.key;
ssl_client_certificate /etc/ssl/ca.crt;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_verify_client on;
location / {
proxy_pass http://app;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
All these certificates are generated using Private CA and client are provided with certificate to connect to backend.
For /etc/ssl/app_domain_com.crt;
Do I need to include entire certificate chain ( Certificate + Intermediate Certificate + Root CA Certificate ) in this file or just Certificate ?
I tried with following
/etc/ssl/cert_example_com.crt
contain only server certificate.
/etc/ssl/cert_example_com.key
contain server key.
/etc/ssl/ca.crt
contain Intermediate CA certificate (Not Root CA).
and at client side
client.crt
contain only client certificate.
client.key
contain client key.
Tested with curl -k --cert client.crt --key client.key --header "Content-Type: application/json" --request POST .....
But got following error
<head><title>400 The SSL certificate error</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<center>The SSL certificate error</center>
<hr><center>nginx/1.19.10</center>
</body>
also tried when client.crt
contain Client Certificate + Intermediate CA + Root CA (in this order). Got same error as above.