Skip to content

Instantly share code, notes, and snippets.

@hogelog
Created August 2, 2012 14:19
Show Gist options
  • Save hogelog/3237391 to your computer and use it in GitHub Desktop.
Save hogelog/3237391 to your computer and use it in GitHub Desktop.
nginxで404の時だけ別サーバから取得してくる ref: http://qiita.com/items/812c028888c1b460f426
server {
listen 8888;
server_name localhost;
location / {
root /tmp/data;
error_page 404 = @data;
}
location @data {
internal;
proxy_pass http://localhost:4567;
proxy_store on;
proxy_store_access user:rw group:r all:r;
proxy_temp_path /tmp/data/temp;
root /tmp/data;
}
}
#!/usr/bin/ruby
require 'sinatra'
get '/*' do
"Generated at #{Time.now.to_s}\n"
end
delete '/:path' do
path = "/tmp/data/#{params[:path]}"
File.unlink path
"delete #{path}\n"
end
$ curl http://localhost:8888/hoge
Generated at 2012-08-02 23:03:25 +0900
$ date
2012年 8月 2日 木曜日 23時03分27秒 JST
$ curl http://localhost:8888/hoge
Generated at 2012-08-02 23:03:25 +0900
$ cat /tmp/data/hoge
Generated at 2012-08-02 23:03:25 +0900
$ curl --request DELETE http://localhost:4567/hoge
delete /tmp/data/hoge
$ curl http://localhost:8888/hoge
Generated at 2012-08-02 23:03:40 +0900
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment