I'm having a bunch of virtual hosts served behind a nginx reverse proxy. At the end of each there is a server that has valid certificates for the given virtual domain.
E.g.
api.example.com -> proxy_pass https://api.example.com; # which resolves locally to a docker instance that has the certificates for api.example.com
Now, my problem is that, the proxy server itself seems to be needing its own certificates and I don't understand why. Since domain names and subdomains don't get encrypted over https, why can't I simply forward the certificate of each proxied server? Or can I? How?
This is what I have so far:
server {
listen 80;
listen [::]:80;
server_name *.example.com;
location / {
proxy_pass http://$http_host$uri$is_args$args;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name *.example.com;
location / {
proxy_pass https://$http_host$uri$is_args$args;
}
}
But the second directive requires certificates.