nginxsslhttpscertbot

Enable HTTPS for both internal and external IPs for EC2 instance


I have an EC2 instance attached to an Elastic IP and serves an REST API to the public through nginx. The FQDN points to the Elastic IP address and there's a working Lets Encrypt SSL cert for that domain. This works great for systems accessing the server from the Internets via HTTPS.

For internal systems that access the same server I want to use the internal IP address of the server instead of the one pointed to by the FQDN to keep traffic inside my VPC. However, of course the SSL cert is tied to the FQDN and clients complain.

How do get this scenario to work so that accessing both the internal and external IP are HTTPS?


Solution

  • Here's how I accomplished this:

    Now I can have internal services access the API via the EC2 internal IP address via HTTPS. And the external services can access the API via the FQDN using the LetsEncrypt-issued cert and HTTPS.