I want to serve an Angular application over HTTPS using ng-serve --host 0.0.0.0
. My project uses Angular CLI 1.2.
Angular is not recognising the certificates I provide, and creating its own. The certificates I want to use are .pem
files.
Enabling the --ssl
flag correctly serves using HTTPS. If I disable it, it goes back to HTTP, so this flag works.
I'm working in a Docker container. I pass the certificates in as a volume in the compose file, and they are where expected in the container when I check with docker exec -i <id> bash
.
Everything works as expected if I ignore the invalid certificate error, both client side and server side. The problem I am trying to solve is getting ng-serve
to use my certificates.
Here's what I've done:
ng-serve --ssl true --ssl-cert <path-to-cert> --ssl-key <path-to-key>
and variations e.g. absolute/relative path.Setting the above flags in the
package.json
file.Setting my
.angular-cli.json
defaults:{ ... "defaults": { ... "serve": { "sslKey": "<relative-path>", "sslCert": "<relative-path>" }, ... }, ... }
I have tried the answers:
Get angular-cli to ng serve over HTTPS
Run Angular Cli Ng Serve over https 2018
The steps in this article also did not work: https://medium.com/@rubenvermeulen/running-angular-cli-over-https-with-a-trusted-certificate-4a0d5f92747a