Skip to content

Instantly share code, notes, and snippets.

View AD7six's full-sized avatar
:shipit:
Busy shippin'

Andy Dawson AD7six

:shipit:
Busy shippin'
View GitHub Profile
@AD7six
AD7six / local-development.conf
Last active August 29, 2015 14:11
Don't think of doing this kind of thing on a live box
set $site $host;
# Strip www. prefix
if ($site ~ "^(w{3}\.)?(.*)$") {
set $site $2;
}
# Strip TLD prefix
if ($site ~ "^(.*)(\.[a-z]{3})$") {
set $site $1;
root@h5bp:~# which nginx
/usr/sbin/nginx
root@h5bp:~# su www-data
$ /usr/sbin/nginx -t
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2014/12/14 10:38:43 [warn] 20279#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:5
2014/12/14 10:38:43 [emerg] 20279#0: unknown directive "i" in /etc/nginx/nginx.conf:120
nginx: configuration file /etc/nginx/nginx.conf test failed
iptables -F
# From https://www.cloudflare.com/ips
for ip in `curl https://www.cloudflare.com/ips-v4`; do
iptables -A INPUT -p tcp -s $ip --dport 80 -j ACCEPT
done
iptables -A INPUT -p tcp --dport 80 -j DROP
Adding phpunit.xml.dist and bootstrap.php to be able to run the unit …
…tests. The tests itself are not yet fixed / updated.
@AD7six
AD7six / readonly.com
Created December 9, 2014 10:19
DNS/hosts file changes to point sites I want to avoid interacting on to a server running nginx; using this config to prevent getting drawn into pointless debates/answering silly questions.
server {
listen 80;
server_name stackoverflow.com;
access_log /var/www/readonly.com/logs/access.log;
error_log /var/www/readonly.com/logs/error.log;
resolver 8.8.8.8 8.8.4.4 216.146.35.35 216.146.36.36;
location / {
@AD7six
AD7six / 0-server.conf
Last active August 29, 2015 14:10
Is try-files significantly worse than using "does file exist?" checks? Does it "only lead[s] to disk iops saturation"?
server {
listen 80 default_server;
root /var/www/try-files-v-file-exists.com;
location ~* /try-files {
try_files $uri /tried.html;
}
location ~* /file-exists {
@AD7six
AD7six / default
Created August 13, 2014 10:30
/etc/default/virtualbox - If you're bored shitless of virtualbox preventing your computer from shutting down cleanly; and concequently needing to check your disks on every boot - this is the file for you to edit
# Defaults for virtualbox initscript
# sourced by /etc/init.d/virtualbox
# installed at /etc/default/virtualbox by the maintainer scripts
#
# This is a POSIX shell fragment
#
# Set this to 1 if you would like the virtualbox modules to be loaded by
# the init script.
@AD7six
AD7six / https-all-the-things.conf
Last active June 21, 2016 07:54
A single redirect for your cloudflare app for http to https, and www.example.com (and olddomain.com etc.) to example.com
# Copy and paste into your .htaccess file or include in your apache conf files
RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"' [OR]
RewriteCond %{HTTP_HOST} !^example.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
# And remember to always use https for future requests
Header set Strict-Transport-Security "max-age=16070400; includeSubDomains"
@AD7six
AD7six / crontab
Last active August 29, 2015 14:03
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">