Skip to content

Instantly share code, notes, and snippets.

@bng44270
Created April 10, 2020 12:48
Show Gist options
  • Select an option

  • Save bng44270/68d69b27faa093db9cd66b65e41d5670 to your computer and use it in GitHub Desktop.

Select an option

Save bng44270/68d69b27faa093db9cd66b65e41d5670 to your computer and use it in GitHub Desktop.
Reverse Proxy Monit through Apache
#####################################
#
# For use with Monit: https://mmonit.com/monit/
#
# New: added search box to top of page
#
# Usage:
# Use MonitProxy /monit 127.0.0.1 2812
# ^--- Make Monit server running on 127.0.0.1:2812 available
# through the parent VirtualHost
#
#####################################
<Macro MonitProxy $path $host $port>
<Location "$path/">
ProxyPass "http://$host:$port/"
RequestHeader unset Accept-Encoding
SetOutputFilter INFLATE;SUBSTITUTE;DEFLATE
Substitute "s|href='|href='$path/|in"
Substitute "s|<meta HTTP-EQUIV='REFRESH' CONTENT=30>||in"
Substitute "s|<head>|<head><link rel=\"shortcut icon\" href=\"$path/favicon.ico\" /><script type=\"text/javascript\" src=\"https://code.jquery.com/jquery-3.1.1.min.js\"></script>|in"
Substitute "s|<center>|<script type=\"text/javascript\">function resetSearch() { $(\"#searchtext\").val(\"\"); $(\"#searchtext\").focus(); $(\"span.red-text,span.green-text\").parent(\"td\").parent(\"tr\").show(); } function searchPage() { $(\"span.red-text,span.green-text\").parent(\"td\").parent(\"tr\").hide();$(\"td:contains('\" + $('#searchtext').val() + \"')\").parent(\"tr\").show(); }</script><div style=\"text-align:center;\"><br/>Search Text: <input type=\"text\" id=\"searchtext\" onKeyPress=\"if (event.keyCode == 13) { searchPage(); } \"/><button type=\"button\" onClick=\"if ($('#searchtext').val().length > 0) { searchPage(); }\">Search</button><button type=\"button\" onClick=\"resetSearch();\">Reset</button><button type=\"button\" onClick=\"if (window.location.search == '\?dorefresh') { location.href = location.href.replace('\?dorefresh',''); } else { location.href = location.href + '\?dorefresh'; }\"><script type=\"text/javascript\">if (window.location.search == '\?dorefresh') { document.write('Turn refresh off'); } else { document.write('Turn refresh on'); }</script></button></div><center>|in"
Substitute "s|<body>|<body onLoad=\"$('#searchtext').focus(); if (window.location.search == '\?dorefresh') { setTimeout(function() { location.href = location.href; }, 30000); }\">|in"
</Location>
ProxyPassReverse $path http://$host:port
</Macro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment