Skip to content

Instantly share code, notes, and snippets.

View olicooper's full-sized avatar

Oli Cooper olicooper

  • Independent
  • United Kingdom
View GitHub Profile
@olicooper
olicooper / nginx_cloudflare_ip_headers.pl
Last active April 9, 2023 18:04
Cloudflare nginx Real-IP header generation written in pearl. Only updates if etag has changed.
#!/usr/bin/perl
###
### Writes a list of 'set_real_ip_from' directives based on current CloudFlare proxy IP addresses.
### This is used to ensure the real client IP is known by NGINX and correctly logged.
### Script usage: /etc/nginx/nginx_cloudflare_ip_headers.pl --silent --update-hook '/usr/sbin/nginx -s reload' '/etc/nginx/snippets/cloudflare_real_ip_header.conf'
### NOTE: Additional perl packages are required to run this script, use 'apt install libwww-perl libjson-perl libreadonly-perl perl-doc'
### Don't forget to add execute permissions too! chmod ug+x /etc/nginx/nginx_cloudflare_ip_headers.pl
use strict;
@olicooper
olicooper / GetHostCertificateInfo.ps1
Created October 3, 2021 12:51
Gets the certificate information for a given host using `System.Net.Sockets.TcpClient`
<#
.SYNOPSIS
Gets the certificate information for a given host using System.Net.Sockets.TcpClient
.DESCRIPTION
Gets the certificate information for a given host, optionally outputting x509 certificate and extended certificate information.
.PARAMETER HostName
The host to connect to.
.PARAMETER SniHostName
When the host uses SNI, this authenticates based on the specified SniHostName.
.PARAMETER Port