Skip to content
Written with Claude
IMPORTANT

As you may notice, this page and pretty much the entire website were obviously created with the help of AI. I wonder how you could tell? Was it a big "Written With Claude" badge on every page? I moved it to the top now (with the help of AI of course) to make it even more obvious. There are a few blogposts that were written by me manually, the old-fashioned way, I hope there will be more in the future, and those have a similar "Human Written" badge. This project (not the website), on the other hand, is a very, very different story. It took me more than two years of painstaking and unpaid work in my own free time. A story that, hopefully, I will tell someday. But meanwhile, what would you like me to do? To create a complex documentation website with a bunch of highly technical articles with the help of AI and fake it, to give you an illusion that I also did that manually? Like the half of itnernet is doing at this point? How does that makes any sense? Is that even fair to you? Or maybe to create this website manually, the old-fashioned way, just for you? While working a paid job for a salary, most of you wouldn't even get up in the morning. Would you like me to sing you a song while we're at it? For your personal entertainment? Seriously, get a grip. Do you find this information less valuable because of the way this website was created? I give my best to fix it to keep the information as accurate as possible, and I think it is very accurate at this point. If you find some mistakes, inaccurancies or problems, there is a comment section at the bottom of every page, which I also made with the help of the AI. And I woould very much appreciate if you leave your feedback there. Look, I'm just a guy who likes SQL, that's all. If you don't approve of how this website was constructed and the use of AI tools, I suggest closing this page and never wever coming back. And good riddance. And I would ban your access if I could know how. Thank you for your attention to this matter.

Server & SSL Settings

This page covers the web server configuration including SSL/HTTPS settings and Kestrel server options.

SSL Configuration

The Ssl section enables HTTPS support and related security features.

json
{
  "Ssl": {
    "Enabled": false,
    "UseHttpsRedirection": true,
    "UseHsts": true
  }
}

Settings Reference

SettingTypeDefaultDescription
EnabledboolfalseEnable Kestrel HTTPS configuration. See UseKestrelHttpsConfiguration.
UseHttpsRedirectionbooltrueRedirect HTTP requests to HTTPS. See UseUseHttpsRedirection.
UseHstsbooltrueAdd the Strict-Transport-Security header (HSTS). See UseHsts.

Enabling HTTPS

To enable HTTPS, set Ssl.Enabled to true and configure your certificates in the Kestrel section:

json
{
  "Ssl": {
    "Enabled": true,
    "UseHttpsRedirection": true,
    "UseHsts": true
  }
}

HTTPS Redirection

When UseHttpsRedirection is true, all HTTP requests are automatically redirected to HTTPS. This ensures users always use the secure connection.

HTTP Strict Transport Security (HSTS)

When UseHsts is true, the server sends the Strict-Transport-Security header, instructing browsers to only access the site over HTTPS for a specified period.

WARNING

HSTS should only be enabled in production environments. It can cause issues during development if you don't have valid certificates configured.

Kestrel Configuration

The Kestrel section configures the underlying web server, including endpoints, certificates, and connection limits.

json
{
  "Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://localhost:5000"
      },
      "Https": {
        "Url": "https://localhost:5001",
        "Certificate": {
          "Path": "/path/to/certificate.pfx",
          "Password": "{CERT_PASSWORD}"
        }
      }
    }
  }
}

For complete Kestrel configuration options, see the Microsoft documentation.

Certificate Configuration

Kestrel supports multiple ways to configure SSL certificates:

PFX File

json
{
  "Kestrel": {
    "Endpoints": {
      "Https": {
        "Url": "https://localhost:5001",
        "Certificate": {
          "Path": "/path/to/certificate.pfx",
          "Password": "{CERT_PASSWORD}"
        }
      }
    }
  }
}

PEM/CRT with Key File

json
{
  "Kestrel": {
    "Endpoints": {
      "Https": {
        "Url": "https://localhost:5001",
        "Certificate": {
          "Path": "/path/to/certificate.pem",
          "KeyPath": "/path/to/private.key",
          "Password": "{KEY_PASSWORD}"
        }
      }
    }
  }
}

Certificate Store (Windows)

json
{
  "Kestrel": {
    "Endpoints": {
      "Https": {
        "Url": "https://localhost:5001",
        "Certificate": {
          "Subject": "localhost",
          "Store": "My",
          "Location": "CurrentUser",
          "AllowInvalid": false
        }
      }
    }
  }
}

Default Certificate

You can define a default certificate used by all HTTPS endpoints:

json
{
  "Kestrel": {
    "Endpoints": {
      "Https": {
        "Url": "https://localhost:5001"
      }
    },
    "Certificates": {
      "Default": {
        "Path": "/path/to/certificate.pfx",
        "Password": "{CERT_PASSWORD}"
      }
    }
  }
}

Connection Limits

Configure connection and request limits to protect your server:

json
{
  "Kestrel": {
    "Limits": {
      "MaxConcurrentConnections": 100,
      "MaxConcurrentUpgradedConnections": 100,
      "MaxRequestBodySize": 30000000,
      "MaxRequestBufferSize": 1048576,
      "MaxRequestHeaderCount": 100,
      "MaxRequestHeadersTotalSize": 32768,
      "MaxRequestLineSize": 8192,
      "MaxResponseBufferSize": 65536,
      "KeepAliveTimeout": "00:02:00",
      "RequestHeadersTimeout": "00:00:30"
    }
  }
}

Limits Reference

SettingDefaultDescription
MaxConcurrentConnectionsnull (unlimited)Maximum number of open connections.
MaxConcurrentUpgradedConnectionsnull (unlimited)Maximum number of upgraded connections (e.g., WebSockets).
MaxRequestBodySize30,000,000 (~28.6 MB)Maximum request body size in bytes.
MaxRequestBufferSize1,048,576 (1 MB)Maximum size of the request buffer.
MaxRequestHeaderCount100Maximum number of request headers.
MaxRequestHeadersTotalSize32,768 (32 KB)Maximum total size of request headers.
MaxRequestLineSize8,192 (8 KB)Maximum size of the request line.
MaxResponseBufferSize65,536 (64 KB)Maximum size of the response buffer.
KeepAliveTimeout2 minutesTimeout for keep-alive connections.
RequestHeadersTimeout30 secondsTimeout for receiving request headers.

HTTP/2 Settings

Configure HTTP/2 specific options:

json
{
  "Kestrel": {
    "Limits": {
      "Http2": {
        "MaxStreamsPerConnection": 100,
        "HeaderTableSize": 4096,
        "MaxFrameSize": 16384,
        "MaxRequestHeaderFieldSize": 8192,
        "InitialConnectionWindowSize": 65535,
        "InitialStreamWindowSize": 65535,
        "KeepAlivePingDelay": "00:00:30",
        "KeepAlivePingTimeout": "00:01:00",
        "KeepAlivePingPolicy": "WithActiveRequests"
      }
    }
  }
}

HTTP/3 Settings

Configure HTTP/3 (QUIC) specific options:

json
{
  "Kestrel": {
    "Limits": {
      "Http3": {
        "MaxRequestHeaderFieldSize": 8192
      }
    }
  }
}

Additional Kestrel Options

json
{
  "Kestrel": {
    "DisableStringReuse": false,
    "AllowAlternateSchemes": false,
    "AllowSynchronousIO": false,
    "AllowResponseHeaderCompression": true,
    "AddServerHeader": true,
    "AllowHostHeaderOverride": false
  }
}
SettingDefaultDescription
DisableStringReusefalseDisable string reuse optimization for debugging.
AllowAlternateSchemesfalseAllow alternate URI schemes in requests.
AllowSynchronousIOfalseAllow synchronous I/O operations (not recommended).
AllowResponseHeaderCompressiontrueEnable response header compression for HTTP/2.
AddServerHeadertrueAdd the Server header to responses.
AllowHostHeaderOverridefalseAllow the Host header to be overridden.

Complete Example

Here's a production-ready configuration with HTTPS enabled:

json
{
  "Urls": "http://localhost:5000;https://localhost:5001",
  "Ssl": {
    "Enabled": true,
    "UseHttpsRedirection": true,
    "UseHsts": true
  },
  "Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://0.0.0.0:5000"
      },
      "Https": {
        "Url": "https://0.0.0.0:5001",
        "Certificate": {
          "Path": "/etc/ssl/certs/myapp.pfx",
          "Password": "{CERT_PASSWORD}"
        }
      }
    },
    "Limits": {
      "MaxConcurrentConnections": 1000,
      "MaxRequestBodySize": 52428800,
      "KeepAliveTimeout": "00:02:00",
      "RequestHeadersTimeout": "00:00:30"
    }
  }
}

Next Steps

Comments

Released under the MIT License.