Using SSl in nginx with identity server 4

In this article I will show you how to implement SSL/TLS in nginx on windows in a very comprehensive and step by step way

0) Download & Install OpenSSL from:
1) Create an OpenSSL config file (example: req.cnf):
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
C = US
L = SomeCity
O = MyCompany
OU = MyDivision
CN =
keyUsage = critical, digitalSignature, keyAgreement
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
DNS.1 =
DNS.2 =
DNS.3 =
Create the certificate referencing this config file by command in cmd:
openssl req -x509 -nodes -days 730 -newkey rsa:2048 \
-keyout cert.key -out cert.crt -config req.cnf -sha256
2) Add the generated certificate in trusted certficates list of Operating sysytem by following steps here:
3) Do configuration in nginx as :
server {
listen 80;
listen 443 default_server ssl;
ssl_certificate #Path to certificate here;
ssl_certificate_key #Path to key here;
other directives
4) In identity server place below code in configure in starup.cs before any other middleware:
5) var fordwardedHeaderOptions = new ForwardedHeadersOptions
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto

Software engineer by profession,Continuous Leaner,Book lover