I have two servers, both have nginx. Server A is listening to 443 and is configured to authenticate with a Client SSL certificate.
Server B has an internal process that needs to communicate to Server A through nginx.
I'd like to configure Nginx on server B that will listen to 8080 (no encryption, since it's all local communication) and proxy_pass to ServerA:443.
The question is how do I inject a Client Certificate ? I didn't found any proxy_xxxx function that would do that.
I do know how to make an equivalent to that with socat, but my requirement is to use nginx.
Is it sufficient to have the client certificate details passed through?
You can add
to your config and then the certificate info is available to server B via a X-SSL-Cert header.
The issue seems to be largely version dependend. On Ubuntu 14.04 LTS the default nginx is an outdated 1.4. First you need to install a PPA based version
https://leftshift.io/upgrading-nginx-to-the-latest-version-on-ubuntu-servers
shows how to do this with:
you should end up with:
The configuration from @xatr0z answer https://serverfault.com/a/636455/162693 pointing to http://www.senginx.org/en/index.php/Proxy_HTTPS_Client_Certificate does not work:
non-working proposal
does not work out of the box with 1.8.0. It's probably meant as a hint only and not to be used as a configuration file as such or depends on another version.
I am testing with a apache2 based backend server A with SSL and self-signed client certificates enabled. The Apache config SSLOptions are set to:
This makes debugging the situation easier since a phpinfo() script on the backend side will show the Server and Client Side information.
To verify this i used:
https://backend/test/phpinfo
with the SSL certificate installed in the browser and I get sections like: SSL_SERVER_S_DN_CN for the server certificate and SSL_CLIENT_S_DN_CN for the client certificate.
As a first start I used (fill in the parts in brackets) to configure nginx on the frontend server B:
uncomenting the SSL Client Certificate specific part just to check that the reverse proxy itself works.
Now http://frontend:8080/test/phpinfo.php works The
SSL_SERVER_S_DN_CN for the server certificate is displayed and SSL_CLIENT_S_DN_CN for the client certificate is not (yet) displayed
Now after uncommenting:
and checking/restarting
http://frontend:8080/test/phpinfo.php works and
SSL_SERVER_S_DN_CN for the server certificate is displayed and SSL_CLIENT_S_DN_CN for the client certificate is displayed
so now we got things working as asked for.
Please note bug https://trac.nginx.org/nginx/ticket/872#ticket
Apparently, this is what you are looking for: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ssl_certificate Available since version 1.7.8.
There's quite a neat article on nginx and SSL client certificates; it uses PHP with FastCGI as the example but I'm think you can be adapt that to a reverse proxy setup:
Source http://nategood.com/client-side-certificate-authentication-in-ngi