Skip to content

Instantly share code, notes, and snippets.

@jbalogh
Created February 11, 2010 21:58
Show Gist options
  • Save jbalogh/302011 to your computer and use it in GitHub Desktop.
Save jbalogh/302011 to your computer and use it in GitHub Desktop.
Serving AMO media and add-on files from a local nginx.
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 5000;
server_name localhost;
location / {
root /Users/jeff/dev/zamboni/;
autoindex on;
}
}
server {
listen 5001;
server_name localhost;
rewrite "collection_icon/(\d{1,3})/" /collection_icons/0/$1;
rewrite "collection_icon/((\d*?)\d{1,3})/" /collection_icons/$2/$1;
rewrite "addon_icon/(\d{1,3})/" /addon_icons/0/$1;
rewrite "addon_icon/((\d*?)\d{1,3})/" /addon_icons/$2/$1;
location / {
root /Users/jeff/dev/remora-images;
autoindex on;
if (-f $request_filename.png) {
rewrite (.*) $1.png last;
}
if (-f $request_filename.jpg) {
rewrite (.*) $1.jpg last;
}
if (-f $request_filename.gif) {
rewrite (.*) $1.gif last;
}
}
}
}
MEDIA_URL = 'http://localhost:5000/media//'
STATIC_URL = 'http://localhost:5001/'
ADDON_ICON_URL = STATIC_URL + 'addon_icon/%d/%s'
PREVIEW_THUMBNAIL_URL = STATIC_URL + 'previews/thumbs/%s/%d.png?modified=%d'
FILES_URL = STATIC_URL + 'downloads/file/%d/%s?src=%s'
COLLECTION_ICON_URL = STATIC_URL + 'collection_icon/%s/%s'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment