Skip to content

Instantly share code, notes, and snippets.

@wsaribeiro
wsaribeiro / default.vcl
Created March 3, 2016 14:35 — forked from derekclee/default.vcl
Varnish Cache Set CORS headers
sub vcl_deliver {
if (req.url ~ "/fonts/") {
set resp.http.Access-Control-Allow-Origin = "*";
set resp.http.Access-Control-Allow-Methods = "GET, OPTIONS";
set resp.http.Access-Control-Allow-Headers = "Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token";
}
}
@wsaribeiro
wsaribeiro / show_img_vars.php
Created March 4, 2016 17:35 — forked from joemcgill/show_img_vars.php
A poor man's var_dump for the image_send_to_editor() filter in Wordpress. Throw this in your functions.php file and add an image to your post to see what get's passed. Filter it however you want to return the image however you want.
<?php
function show_img_vars($html, $id, $caption, $title, $align, $url, $size, $alt) {
// round up all the variables that get passed so we can test them
$vars = "html = $html\n";
$vars .= "id = $id\n";
$vars .= "caption = $caption\n";
$vars .= "title = $title\n"; // this will end up blank no matter what
$vars .= "align = $align\n";
$vars .= "url = $url\n";
@wsaribeiro
wsaribeiro / letsencrypt.md
Created March 9, 2016 15:00 — forked from g-p-g/letsencrypt.md
Using letsencrypt

Download

git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt

Generate SSL certificate

server {
listen 80;
server_name observium.yourdomain.com;
access_log /var/log/nginx/observium-access_log combined;
error_log /var/log/nginx/observium-error_log warn;
root /opt/observium/html;
client_max_body_size 10m;
client_body_buffer_size 8K;
##########
# GZIP
##########
gzip on;
gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
##########
# CACHE
##########
location ~ \.(css|htc|less|js|js2|js3|js4)$ {
@wsaribeiro
wsaribeiro / nginx.conf
Created March 11, 2016 17:09 — forked from sgnn7/nginx.conf
NGINX caching
# vim:ff=unix:ts=2:sw=2:ai:expandtab
# Cache location setup - this should be the NAS
proxy_cache_path /var/cache/nginx
levels=1:2
keys_zone=bundle-cache:8M
max_size=100000M
inactive=3M
loader_threshold=330
loader_files=1000;
@wsaribeiro
wsaribeiro / 000_cache.conf
Created March 11, 2016 17:10 — forked from evandhoffman/000_cache.conf
nginx cache config
proxy_cache_path /var/lib/nginx/cache/staticfiles levels=1:2 keys_zone=staticfilecache:10m max_size=50m;
proxy_cache_path /var/lib/nginx/cache/php levels=2:2 keys_zone=php:10m inactive=20m max_size=50m;
proxy_temp_path /var/lib/nginx/proxy;
proxy_connect_timeout 30;
proxy_read_timeout 120;
proxy_send_timeout 120;
#IMPORTANT - this sets the basic cache key that's used in the static file cache.
proxy_cache_key "$scheme://$host$request_uri";
http {
proxy_cache_path /tmp/cache levels=1:2 keys_zone=photo-cache:8m max_size=5000m inactive=43829m;
proxy_cache_key $host$uri$is_args$args;
server {
proxy_cache photo-cache;
listen 80;
server_name cdn.matsimitsu.com;
access_log logs/cdn.access.log;
@wsaribeiro
wsaribeiro / wordpress.vcl
Created March 11, 2016 20:32 — forked from onyxfish/wordpress.vcl
ChicagoNow Varnish configuration (development version)
backend app1 {
.host = "127.0.0.1";
.port = "8000";
}
acl purge {
"127.0.0.1";
"::1";
}
import std;
backend default {
.host = "127.0.0.1";
.port = "8080";
.first_byte_timeout = 60s;
.connect_timeout = 60s;
.between_bytes_timeout = 60s;
.max_connections = 200;