Skip to content

Instantly share code, notes, and snippets.

@alecslupu
Created July 9, 2013 21:53
Show Gist options
  • Save alecslupu/5961605 to your computer and use it in GitHub Desktop.
Save alecslupu/5961605 to your computer and use it in GitHub Desktop.
upstream upstream_name {
server localhost:8022;
}
server {
listen 80;
server_name payments.myhost;
access_log /var/log/nginx/www.host.access.log;
error_log /var/log/nginx/www.host.error.log;
root /home/sites/path/current/public/;
index index.html;
set $upstr upstream_name;
# Feeds
if ($request_filename ~ ^.*/feed/.*$) {
rewrite ^(.*)$ http://feeds.myhost$1 break;
}
if ($args ~ ^(.*)widget_store(.*)$) {
set $args $1product_store$2;
rewrite ^ http://myhost/$uri permanent;
}
location ~ /blog {
rewrite ^ http://blog.myhost permanent;
}
location ~ /images/(banners|bassets)/(fullsize|thumb)/.+(\.gif|\.jpg|\.png|\.swf) {
break;
}
location ~ /system/paperclip/.+ {
break;
}
location ~ /ad_groups/embed {
if ($args ~ ^aff_code=(.*)&unique=(.*)$) {
set $affcode $1;
set $unique $2;
set $args '';
rewrite ^/ad_groups/embed http://my_host/ad_group/${unique}_${affcode}.js permanent;
}
}
location = /robots.txt {
if ($host ~* ^(img|api|event)\..*) {
rewrite ^.*$ /robots_deny_all.txt;
}
}
location ~ ^/ipn/payu {
auth_basic off;
satisfy any;
allow 91.0.0.0;
deny all;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_buffering off;
proxy_read_timeout 3600s;
proxy_next_upstream error timeout invalid_header http_500;
proxy_connect_timeout 2;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://$upstr;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment