Report this

What is the reason for this report?

How may I config SSL Certificate on nginx/1.25.2 in my Windows Server 2022?

Posted on October 6, 2023

Hi, I hope all is well

I have nginx/1.25.2 in my Windows server 2022 on my Drive Z. I wanted to install my domain SSL on it! But I couldn’t!

Can any body help me step by step, please?

I am waiting for your reply

Thank You



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya @alinejadbahram,

Setting up SSL on Nginx, even on Windows, follows a somewhat similar procedure as on Linux. Here’s a step-by-step guide to help you set up SSL for your domain on Nginx running on your Windows Server:

  1. Obtain SSL Certificate for Your Domain:

    • I’ll skip this line as I assume you already have an SSL.
  2. Place the Certificates in an Accessible Directory:

    • Once you’ve got your certificates (typically fullchain.pem and privkey.pem or their .crt and .key equivalents), place them in a directory on your server, for instance, Z:\nginx\ssl\.
  3. Update Your Nginx Configuration:

    • Open your your domain’s Nginx configuration file…
    • Inside the server block for your domain, add the following:
listen 443 ssl;
server_name yourdomain.com www.yourdomain.com;

ssl_certificate Z:/nginx/ssl/fullchain.pem;
ssl_certificate_key Z:/nginx/ssl/privkey.pem;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384';

# Other configurations...

Replace yourdomain.com with your actual domain name and adjust the paths to point to where you’ve placed your SSL certificates. 4. Redirect HTTP to HTTPS (Optional): If you want to force redirect all HTTP traffic to HTTPS, you can add another server block like this:

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;
    return 301 https://$host$request_uri;
}
  1. Test Configuration and Reload:
  • Before applying changes, it’s always a good idea to test your Nginx configuration for syntax errors:
nginx -t
nginx -s reload

Heya,

In addition to what’s has been already mentioned, you can check this article on Microsoft’s documentation on how to install SSL as well.

https://learn.microsoft.com/en-us/troubleshoot/windows-server/windows-security/install-imported-certificates

Regards

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.