Skip to content

Instantly share code, notes, and snippets.

@aarellano
Created July 22, 2013 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarellano/6055932 to your computer and use it in GitHub Desktop.
Save aarellano/6055932 to your computer and use it in GitHub Desktop.
Nginx configuration
upstream php {
server unix:/var/run/php5-fpm.socket;
}
# Non-www redirect
server {
listen 80;
# listen on the non-www host
server_name quehambre.cl;
# and redirect to the www host (declared below)
return 301 $scheme://www.quehambre.cl$request_uri;
}
# Alianza site
server {
listen 80;
server_name alianza.quehambre.cl;
root /quehambre/www/online;
# Logging
access_log /mnt/var/log/quehambre.access.log main;
error_log /mnt/var/log/quehambre.error.log notice;
rewrite_log on;
# Upload max size
client_max_body_size 20m;
client_body_buffer_size 128k;
# Specify a charset
charset utf-8;
# Handle PHP site
index index.php;
location ~ (get|api) {
try_files $uri $uri/ /index.php$is_args$args;
}
location / {
rewrite ^(.*)$ /index.php/get$1;
}
location ~ \.php {
include fastcgi_params;
fastcgi_pass php;
fastcgi_param PHP_VALUE "include_path=/quehambre/www/libs";
}
}
# Main site
server {
listen 80;
server_name www.quehambre.cl;
root /quehambre/www/online;
# Logging
access_log /mnt/var/log/quehambre.access.log main;
error_log /mnt/var/log/quehambre.error.log notice;
# Upload max size
client_max_body_size 20m;
client_body_buffer_size 128k;
# Specify a charset
charset utf-8;
# Handle PHP site
index index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php;
fastcgi_param PHP_VALUE "include_path=/quehambre/www/libs";
}
}
# Static
server {
listen 80;
server_name static1qh.voxolutions.com static2qh.voxolutions.com;
root /quehambre/www/online;
### Rewrite static files for cache bust
# All static files
location ~* ^/a/\d*/(.*).(js|css|png|jpg|jpeg|gif)$ {
try_files $uri /$1.$2;
}
# Spots logos
location ~* ^/[li]/[0-9a-f]*/(.*).(png|jpg|jpeg|gif)$ {
try_files $uri /fixedImages/logos/$1.$2;
}
# Menu item photos
location ~* ^/m/[0-9a-f]*/(.*).(png|jpg|jpeg|gif)$ {
try_files $uri /fixedImages/manus/$1.$2;
}
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}
# Cross domain webfont access
location ~* \.(?:ttf|ttc|otf|eot|woff|font.css)$ {
add_header "Access-Control-Allow-Origin" "*";
# Also, set cache rules for webfonts.
#
# See http://wiki.nginx.org/HttpCoreModule#location
# And https://github.com/h5bp/server-configs/issues/85
# And https://github.com/h5bp/server-configs/issues/86
expires 1M;
access_log off;
add_header Cache-Control "public";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment