Skip to content

Instantly share code, notes, and snippets.

View dcnl1980's full-sized avatar

TheDev dcnl1980

View GitHub Profile
@dcnl1980
dcnl1980 / nginx-tls.conf
Last active June 13, 2016 12:23
Nginx SSL/TLS configuration for "A+" Qualys SSL Labs rating
#
# Name: nginx-tls.conf
# Auth: Chris van Steenbergen <[email protected]>
# Date: 13 June 2016
# Desc: Nginx SSL/TLS configuration for "A+" Qualys SSL Labs rating
#
# Enables HTTP2, PFS, HSTS and OCSP stapling. Configuration options not related
# to SSL/TLS are omitted here.
#
# Preparation: Strong 4096 bits DHE parameters (takes time)
@dcnl1980
dcnl1980 / create-slugs.php
Created August 6, 2016 14:40
Create Slugs in large MYSQL tables
<?php
// This script must be run on a command line
error_reporting(E_ALL);
set_time_limit(1200);
date_default_timezone_set("Europe/Amsterdam");
$mysqli = new mysqli('localhost', 'username', 'password', 'table');
if ($mysqli->connect_error) {
@dcnl1980
dcnl1980 / nginx-cookieless.conf
Last active September 17, 2021 02:48
Nginx Cookieless Domain
#
# Name: nginx-cookieless.conf
# Auth: Chris van Steenbergen <[email protected]>
# Date: 12 August 2016
# Desc: Nginx Cookieless Domain configuration for 100% performance grade with
#
# See for yourself at: https://tools.pingdom.com/#!/beJG0v/http://www.reclick.nl
#
server {
@dcnl1980
dcnl1980 / zabbix-server.sh
Created November 28, 2016 21:57
Zabbix Server Installation
#!/bin/sh
apt update && apt install wget htop curl nano ssh -y
wget http://repo.zabbix.com/zabbix/3.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.2-1+xenial_all.deb
dpkg -i zabbix-release_3.2-1+xenial_all.deb && apt-get update
export DEBIAN_FRONTEND=noninteractive
apt install zabbix-server-mysql zabbix-frontend-php -y
@dcnl1980
dcnl1980 / hipchat-server.sh
Created November 28, 2016 21:59
Install the HipChat Server
sudo su
echo "deb http://downloads.hipchat.com/linux/apt stable main" > /etc/apt/sources.list.d/atlassian-hipchat.list
wget -O - https://www.hipchat.com/keys/hipchat-linux.key | apt-key add -
apt-get update
apt-get install hipchat
@dcnl1980
dcnl1980 / nginx-naxsi.sh
Created November 28, 2016 22:00
Nginx Naxsi (firewall) on Ubuntu 16.04
#!/usr/bin/env bash
apt-get install -y libpcre3 libpcre3-dev libssl-dev unzip make \
libgoogle-perftools-dev google-perftools jq
mkdir /tmp/ngxbuild
cd /tmp/ngxbuild
latestNginx=$(curl -s http://hg.nginx.org/nginx/tags |
grep "^ *release-" | head -1 | cut -c 9-)
latestNaxsi=$(curl -s https://api.github.com/repos/nbs-system/naxsi/releases |
jq -r .[].tag_name | grep -v rc | head -1)
@dcnl1980
dcnl1980 / naxsi_core.rules
Created November 29, 2016 08:45
Naxsi Rules Conf
##################################
## INTERNAL RULES IDS:1-999 ##
##################################
#@MainRule "msg:weird request, unable to parse" id:1;
#@MainRule "msg:request too big, stored on disk and not parsed" id:2;
#@MainRule "msg:invalid hex encoding, null bytes" id:10;
#@MainRule "msg:unknown content-type" id:11;
#@MainRule "msg:invalid formatted url" id:12;
#@MainRule "msg:invalid POST format" id:13;
#@MainRule "msg:invalid POST boundary" id:14;
@dcnl1980
dcnl1980 / backup-linux.sh
Last active November 29, 2016 12:50
Linux backup script
#/bin/sh
# This file is under construction and will be update regulary, so it can be a cron-shell for backing up Linux based systems.
# put this in the cronjob to run the backup every day at 2:15
# 15 2 * * * /var/backups/backup.sh
current="$(date +'%d_%m_%Y_%H_%M_%S')"
# MYSQL BACKUP
sudo mysqldump -u root -pPASSWORD --all-databases | gzip > /var/backups/dbbackup_$current.sql.gz
# WEBSITES BACKUP
sudo tar czf /var/backups/sitebackup_$current.tar -C / var/www && gzip /var/backups/sitebackup_$current.tar
# DELETE OLD BACKUPS > 7 days
@dcnl1980
dcnl1980 / build-nginx-naxsi.sh
Created December 20, 2016 15:51
Build the latest Nginx with NAXSI
#!/usr/bin/env bash
apt-get install -y libpcre3 libpcre3-dev libssl-dev unzip make \
libgoogle-perftools-dev google-perftools jq
mkdir /tmp/ngxbuild
cd /tmp/ngxbuild
latestNginx=$(curl -s http://hg.nginx.org/nginx/tags |
grep "^ *release-" | head -1 | cut -c 9-)
latestNaxsi=$(curl -s https://api.github.com/repos/nbs-system/naxsi/releases |
jq -r .[].tag_name | grep -v rc | head -1)
@dcnl1980
dcnl1980 / nginx-add-virtualhost.sh
Created December 27, 2016 21:51
Creating NGINX virtualhost
#!/bin/bash
# Modify the following to match your system
NGINX_CONFIG='/etc/nginx/sites-available'
NGINX_SITES_ENABLED='/etc/nginx/sites-enabled'
PHP_INI_DIR='/etc/php5/fpm/pool.d'
WEB_SERVER_GROUP='www-data'
NGINX_INIT='/etc/init.d/nginx'
PHP_FPM_INIT='/etc/init.d/php5-fpm'
# --------------END