Skip to content

Instantly share code, notes, and snippets.

@RJ
Created December 21, 2012 01:23
Show Gist options
  • Save RJ/4350070 to your computer and use it in GitHub Desktop.
Save RJ/4350070 to your computer and use it in GitHub Desktop.
Apache2 conf snippit to proxy and rewrite URLs for graphite. https://graphite-admin.example.com ---> https://admin.example.com/graphite Used on a dashboard page that includes graphs from various other domains, and it was annoying typing basic-auth passwords all the time.
SSLProxyEngine on
# Graphite URLs that are buried in JS that we can't easily rewrite, we issue an http redirect
# - /content/js/ext/resources/images/default/s.gif
# - /render
RewriteEngine On
RewriteCond %{HTTP_HOST} ^admin\.example\.com [NC]
RewriteRule ^/content/js/ext/resources/images/default/s.gif https://graphite-admin.example.com/content/js/ext/resources/images/default/s.gif [L,R]
RewriteRule ^/render https://graphite-admin.example.com/render [L,R]
<Location /graphite>
ProxyPass https://graphite-admin.example.com
ProxyPassReverse https://graphite-admin.example.com
SetOutputFilter INFLATE;proxy-html;DEFLATE
# Don't mess with anchors
ProxyHTMLUrlMap ^#(.*) #$1 [R,L]
# Or with relative urls
ProxyHTMLUrlMap ^([^/].*) $1 [R,L]
ProxyHTMLUrlMap ^https://grapite-admin.example.com/(.*) https://admin.example.com/grapite/$1 [R,L]
ProxyHTMLUrlMap (.*) https://admin.example.com/graphite/$1 R
</Location>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment