Create a gist now

Instantly share code, notes, and snippets.

Pagespeed for nginx on octohost
pagespeed on;
# Needs to exist and be writable by nginx. Use tmpfs for best performance.
pagespeed FileCachePath /var/ngx_pagespeed_cache;
pagespeed RewriteLevel PassThrough;
pagespeed StatisticsPath /ngx_pagespeed_statistics;
pagespeed GlobalStatisticsPath /ngx_pagespeed_global_statistics;
pagespeed MessagesPath /ngx_pagespeed_message;
pagespeed ConsolePath /pagespeed_console;
pagespeed AdminPath /pagespeed_admin;
pagespeed GlobalAdminPath /pagespeed_global_admin;
pagespeed EnableFilters combine_css,rewrite_css;
pagespeed EnableFilters combine_javascript,rewrite_javascript;
pagespeed EnableFilters remove_comments;
pagespeed EnableFilters collapse_whitespace;
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; }
location /ngx_pagespeed_global_statistics { allow 127.0.0.1; deny all; }
location /ngx_pagespeed_message { allow 127.0.0.1; deny all; }
location /pagespeed_console { allow 127.0.0.1; deny all; }
location /pagespeed_admin { allow 127.0.0.1; deny all; }
location /pagespeed_global_admin { allow 127.0.0.1; deny all; }
user www-data;
worker_processes 4;
pid /var/run/proxy.pid;
events {
worker_connections 2048;
multi_accept on;
use epoll;
}
http {
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;
types_hash_max_size 2048;
variables_hash_max_size 1024;
server_names_hash_max_size 1024;
server_names_hash_bucket_size 128;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Containers - built by consul-template
include /etc/nginx/containers/*;
# Additional directory, for manually configured vhosts
include /etc/nginx/additional-vhosts/*;
# Open File Cache
open_file_cache max=10000 inactive=10m;
open_file_cache_valid 20m;
open_file_cache_min_uses 1;
open_file_cache_errors on;
# GeoIP
geoip_country /usr/local/share/GeoIP/GeoIP.dat;
geoip_city /usr/local/share/GeoIP/GeoLiteCity.dat;
# Connection log with $txid.
log_format connection '$txid conn:$connection reqs:$connection_requests pipe:$pipe';
access_log /var/log/nginx/connection.log connection;
# Log with standard information and global $txid.
log_format octohost '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" "$host" "$txid"';
access_log /var/log/nginx/access.log octohost;
# SSL Certificate.
ssl_certificate /etc/nginx/ssl.crt;
ssl_certificate_key /etc/nginx/ssl.key;
include /etc/nginx/pagespeed.conf;
}
upstream REPLACEME {
ip_hash;
{{range service "REPLACEME"}}server {{ .Address }}:{{ .Port }};
{{else}}server 127.0.0.1:404;
{{end}}
}
server {
listen 80;
listen 443 ssl spdy;
include /etc/nginx/ssl.conf;
include /etc/nginx/pagespeed_common.conf;
server_name {{key "octohost/REPLACEME/DOMAINS"}};
location / {
include /etc/nginx/location.conf;
proxy_pass http://REPLACEME;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment