in nginx.conf (or a file included in nginx.conf)
you should already have a 'server' directive in it else your http would not be served.
You have to add another with something like
server {
listen *:443 ssl http2;
ssl_certificate /path/to/fullchain.pem;
ssl_certificate_key /path/to/privkey.pem;
(...see nginx doc and tutorials...)
That's what @JuergenAuer is referring to when he is writing about 'vHost' (that's more an Apache term)
This api.example.com uses a different IP address to the main www.example.com. Thus do I have to configure the 443 server in as
server {
listen *:443 ssl http2;
server_name www.example.com
…
}
I gather that
13.xxx.xxx.xxx has to have a https directive but there is no certificates for the IP address. Does that mean that the IP has to be encrypted as well?
Yes the server_name directive should match your server name (duh.)
And the rest should look similar to your http (port 80) server section; with the addition of ssl directives of course (I did not look precisely but it’s certain that at least ssl_certificate and ssl_certificate_key directive should be present and point at your certificates - other directives can be present such as ssl_protocols, ssl_ciphers, and others but I’m not sure these are mandatory)
Normally you don’t use certificates with IP addresses (you don’t use pure IP addresses at all in modern Web)