Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# A quick nginx config that does some shameless transparent proxying.
# The sub_filter module is available on my ubuntu install out of the box, but may not always be available
# This demonstration of sub_filter is also extremely minimal. All requests that begin with `/` will load relatively anyways, this attempts to replace any fully qualified requests
server {
listen 80;
listen [::]:80;
return 301 https://$server_name$request_uri;
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/;
ssl_certificate_key /etc/letsencrypt/live/;
location ~ /.well-known {
allow all;
location / {
proxy_set_header Host;
proxy_ssl_server_name on;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
sub_filter_once off;
sub_filter '' '';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment