Skip to content

Instantly share code, notes, and snippets.

@diyfr
diyfr / docker-compose.yml
Last active May 1, 2023 05:34
Basic secured configuration for Traefik V2.X
version: '3.5'
services:
proxy:
image: traefik:v2.1
# The official v2.0 Traefik docker image
container_name: proxy
networks:
- traefik
ports:
@marcopaganini
marcopaganini / nginx_reverse_proxy_with_ssl_cert_authentication.md
Last active December 8, 2023 19:38
NGINX reverse proxy with SSL cert authentication

NGINX reverse proxy with SSL cert authentication

This is a short guide for those who want to set up a NGINX reverse proxy with SSL cert authentication. The basic idea is to create a private CA and emit certificates signed by it. Only browsers and/or devices with the certs signed by this CA will be granted access to resources behind the proxy.

There are a few examples of similar configurations on the web, but most use openssl directly. This gist uses Easy-RSA to simplify the task of creating and maintaining a private CA and certs to be distributed to clients.

Install and configure Easy-RSA

Clone Easy-RSA 3:

@endpnt
endpnt / text_selection_with_childNodes.js
Created April 19, 2011 00:32
find actual text start and end position of a selected text, even with childNodes present.
var offset = 0;
var selection = window.getSelection();
var range = selection.getRangeAt(0);
var start = range.startOffset;
var end = range.endOffset;
if ( selection.baseNode.parentNode.hasChildNodes() ) {
for ( var i = 0 ; selection.baseNode.parentNode.childNodes.length > i ; i++ ) {
var cnode = selection.baseNode.parentNode.childNodes[i];
if (cnode.nodeType == document.TEXT_NODE) {