I am working on an Angular 6 application that is deployed on a Pivotal Cloud Foundry, using the nginx-buildpack. With the default nginx.conf, http and https requests are served. The https request is secured using the certificate for *cfapps.io, which is nice to have without any configuration.
However, allowing http requests opens the door for accidental unencrypted logins, which I want to avoid. Hence, I want to forward all http-requests to https.
Here’s the working nginx.conf for this:
This is the complete configuration file. Only the last part is important for the redirect. However, the rest may serve as reference for future-me. You’re welcome, Steven! ;)