Click here to Skip to main content
15,885,652 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello all,
I currently have my project running http without any issues. Now I am working on encrypting my traffic by using https. I have a certificate for my domain and I set up all the code and areas I thought were necessary to deploy it as https.
When I do this and run it my web page is not displayed, I just get the default nginx page. When I do this with http my web page is displayed.
Here are all the steps I used for setting up my certificate and deploying it as HTTPS:

What I have tried:

C#
1.	.Net Core Project.
Appsettings.json I added these 2 sections.
"Kestrel": {
    "Endpoints": {
        "Http": {
            "Url": "http://localhost:60110"
        },
        "Https": {
            "Url": "https://localhost:60111"
        }
    }
},
"https_port": 60111

2.	Program.cs
public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>()
                    .UseUrls(@"http://*:60110")
                    .UseUrls(@"https://*:60111")
			   .UseKestrel();
                });
3.	Startup.cs
I added app.UseHsts();

4.	Nginx I have 2 vhost files. 1 is for my ‘listen 80;" which works.
My 2nd is this :
server {
    listen 443 ssl;

    ssl_certificate 	 /path/to/fullchain.pem #managed by Certbot
    ssl_certificate_key	/path/to/privkey.pem    #managed by Certbot

    root /var/www/websiteFolder;

    server_name MyDomain.tech

    location / {

        proxy_pass         https://localhost:60111;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;}


}


5. I setup the symbolic link in nginx/sites-enabled from sites-available
I did the sudo nginx -t and my syntax passes.
I also did the nginx -s reload to reload all my conf and vhost files on nginx.

What am I missing or did I do wrong?
Thank you all.
Posted
Updated 3-Nov-21 11:29am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900