Created
August 2, 2012 14:19
-
-
Save hogelog/3237391 to your computer and use it in GitHub Desktop.
nginxで404の時だけ別サーバから取得してくる ref: http://qiita.com/items/812c028888c1b460f426
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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