Skip to content

Commit 13acaf7

Browse files
authored
Enforce that the SNI name matches the host name (#170)
Problem: Nginx does not enforce that the SNI name matches the host name for SSL requests, which can lead to unexpected behavior and breaks the recommendation of the gateway API spec. Fix: in every SSL server block, we now check that the variables $ssl_server_name and $host are equal. If they are not, we return a 421 misdirected request.
1 parent bf34e2f commit 13acaf7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/nginx/config/template.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ server {
2626
listen 443 ssl;
2727
ssl_certificate {{ $s.SSL.Certificate }};
2828
ssl_certificate_key {{ $s.SSL.CertificateKey }};
29+
30+
if ($ssl_server_name != $host) {
31+
return 421;
32+
}
2933
{{ end }}
3034
3135
server_name {{ $s.ServerName }};

0 commit comments

Comments
 (0)