Skip to content

Instantly share code, notes, and snippets.

@glorat
Created September 24, 2024 06:45
Show Gist options
  • Save glorat/adc43f534a55e35dac5259e35905a233 to your computer and use it in GitHub Desktop.
Save glorat/adc43f534a55e35dac5259e35905a233 to your computer and use it in GitHub Desktop.
Posthog Reverse proxy for nginx
FROM nginx:alpine
COPY nginx.conf /etc/nginx/nginx.conf
# The main context
events {
worker_connections 1024;
}
http {
server {
listen 8080; # Set the port to 8080
server_name _; # Accept requests for any domain
# Check Referer header
# Customise as needed to ensure requests only come from your domain
set $valid_referer 0;
if ($http_referer ~* "^https?://(localhost|([a-zA-Z0-9-]+)\.brieftech\.ai)") {
set $valid_referer 1;
}
if ($valid_referer = 0) {
return 403; # Return forbidden if the Referer header is invalid
}
location /static/ {
proxy_pass https://eu-assets.i.posthog.com/static/;
proxy_set_header Host eu-assets.i.posthog.com;
}
location / {
proxy_pass https://eu.i.posthog.com/;
proxy_set_header Host eu.i.posthog.com;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment