Skip to content

Instantly share code, notes, and snippets.

@pnck
pnck / 01nginx-tls-sni.md
Created June 23, 2023 21:00 — forked from kekru/01nginx-tls-sni.md
nginx TLS SNI routing, based on subdomain pattern

Nginx TLS SNI routing, based on subdomain pattern

Nginx can be configured to route to a backend, based on the server's domain name, which is included in the SSL/TLS handshake (Server Name Indication, SNI).
This works for http upstream servers, but also for other protocols, that can be secured with TLS.

prerequisites

  • at least nginx 1.15.9 to use variables in ssl_certificate and ssl_certificate_key.
  • check nginx -V for the following:
    ...
    TLS SNI support enabled
@pnck
pnck / LspWslFix.ps1
Last active April 15, 2023 08:07 — forked from mariotaku/LspWslFix.ps1
Fix WSL Connection Issue Caused by Winsock
#Requires -RunAsAdministrator
# Fix for https://github.com/microsoft/WSL/issues/4177
$MethodDefinition = @'
[DllImport("ws2_32.dll", CharSet = CharSet.Unicode)]
public static extern int WSCSetApplicationCategory([MarshalAs(UnmanagedType.LPWStr)] string Path, uint PathLength, [MarshalAs(UnmanagedType.LPWStr)] string Extra, uint ExtraLength, uint PermittedLspCategories, out uint pPrevPermLspCat, out int lpErrno);
'@
$Ws2Spi = Add-Type -MemberDefinition $MethodDefinition -Name 'Ws2Spi' -PassThru
@pnck
pnck / create-cert.sh
Last active December 2, 2020 10:23 — forked from sethvargo/create-certs.sh
x509 v3 self signed certificate
# Define where to store the generated certs and metadata.
DIR="$(pwd)"
# Create the openssl configuration file. This is used for both generating
# the certificate as well as for specifying the extensions. It aims in favor
# of automation, so the DN is encoding and not prompted.
cat > "${DIR}/openssl.cnf" << EOF
[req]
default_bits = 2048
@pnck
pnck / ipv6-httpd.py
Last active November 9, 2018 03:58 — forked from akorobov/ipv6-httpd.py
quick ipv6 http server using python's SimpleHttpServer
import http.server
from http.server import SimpleHTTPRequestHandler
import socketserver
import socket
import sys
class MyHandler(SimpleHTTPRequestHandler):
def do_GET(self):
if self.path == '/__ip__':
self.send_response(200)