Created
September 24, 2024 06:45
-
-
Save glorat/adc43f534a55e35dac5259e35905a233 to your computer and use it in GitHub Desktop.
Posthog Reverse proxy for nginx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM nginx:alpine | |
COPY nginx.conf /etc/nginx/nginx.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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