Skip to content

Instantly share code, notes, and snippets.

@alexcreek
alexcreek / return-address.php
Last active August 29, 2015 14:03
Usage: curl [FILE] - returns WAN IP address
<?php
$ua = getenv('HTTP_USER_AGENT');
$ip = getenv('REMOTE_ADDR');
if (strpos($ua,'curl') !== false) {
echo "$ip \n";
}
?>
@alexcreek
alexcreek / apache-debug.php
Last active August 29, 2015 14:07
Display every apache variable and request header using php
<?php
echo "<h1>REQUEST HEADERS</h1>";
$headers = apache_request_headers();
foreach ($headers as $header => $value) {
echo "$header: $value <br />\n";
}
echo "<h1>APACHE VARIABLES</h1>";
@alexcreek
alexcreek / apache-ssl-vhost.conf
Last active August 29, 2015 14:07
SSL enabled virtualhost template
<VirtualHost *:443>
ServerName securesite.com
ServerAlias www.securesite.com
DocumentRoot /var/www/securesite.com
# OCSP Stapling
SSLStaplingCache shmcb:/tmp/stapling_cache(128000) # place outside <virtualhost></virtualhost>
SSLCACertificateFile /etc/ssl/ca-certs.pem
SSLUseStapling on
@alexcreek
alexcreek / iptables-template
Last active August 29, 2015 14:07
basic iptables ruleset
# Generated by iptables-save v1.4.12 on Tue Oct 21 17:32:08 2014
*nat
:PREROUTING ACCEPT [9:538]
:INPUT ACCEPT [9:538]
:OUTPUT ACCEPT [4:271]
:POSTROUTING ACCEPT [4:271]
COMMIT
# Completed on Tue Oct 21 17:32:08 2014
# Generated by iptables-save v1.4.12 on Tue Oct 21 17:32:08 2014
*mangle
@alexcreek
alexcreek / kibana-reverse-proxy.conf
Last active August 29, 2015 14:08
nginx reverse proxy config for kibana, includes authentication, ssl and support for elasticsearch plugins
server {
listen *:80 ;
#listen *:443;
server_name localhost;
access_log /var/log/nginx/kibana.access.log;
#ssl on;
#ssl_certificate /etc/nginx/ssl/logstash.pem;
#ssl_certificate_key /etc/nginx/ssl/logstash.pem;
@alexcreek
alexcreek / zpanel-ssl.conf
Last active February 2, 2016 04:37
apache config for enabling SSL on the zpanel login
# Configuration for ZPanel control panel.
# /etc/zpanel/configs/apache/zpanel-ssl.conf
# to use this config append the include directive below to /etc/zpanel/configs/apache/httpd.conf
# Include /etc/zpanel/configs/apache/zpanel-ssl.conf
<VirtualHost *:443>
ServerAdmin zadmin@localhost
DocumentRoot "/etc/zpanel/panel/"
ServerName www.foo.bar
@alexcreek
alexcreek / weighttp-output.patch
Created April 15, 2014 00:54
Modifies weighttp's output for easier grepping
diff -rupN /home/alex/source/weighttp/src/weighttp.c weighttp/src/weighttp.c
--- /home/alex/source/weighttp/src/weighttp.c 2014-04-13 14:05:00.359685093 -0400
+++ weighttp/src/weighttp.c 2014-04-14 20:34:59.470388698 -0400
@@ -234,6 +234,7 @@ int main(int argc, char *argv[]) {
uint64_t kbps;
char **headers;
uint8_t headers_num;
+ float full_duration;
printf("weighttp - a lightweight and simple webserver benchmarking tool\n\n");
@alexcreek
alexcreek / bench.sh
Last active February 3, 2016 23:33
wrapper for weighttp
#!/bin/bash
REQUESTS=( 50 100 200 400 800 1600 3200 5000 )
USERS=( 5 10 20 40 80 160 320 500 )
LOG=/tmp/bench.log
REQ_LOG=/tmp/req.log
TIME_LOG=/tmp/time.log
WEBSERVER=[enter webserver IP] # used to remotely restart apache
# Argument checking
if [[ $# -ne 2 ]]; then
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
KillMode=none
ExecStartPre=/usr/sbin/nginx -t
ExecStartPre=-/usr/bin/pkill -SIGQUIT nginx
@alexcreek
alexcreek / check_connections
Created August 15, 2014 05:25
nagios plugin to monitor TCP/UDP connections
#!/bin/bash
if [[ $# -ne 2 ]]; then
echo "WARN and CRIT thresholds not defined"
exit 3
fi
warn="$1"
crit="$2"
tcp=$(ss -tan | tail -n +3 | egrep -c -v "UNCONN|LISTEN")