Skip to content

Instantly share code, notes, and snippets.

@omnifroodle
Created May 25, 2011 22:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omnifroodle/992139 to your computer and use it in GitHub Desktop.
Save omnifroodle/992139 to your computer and use it in GitHub Desktop.
Rackup file for limiting access to a reverse proxied solr instance (thinking ajax)
# config.ru for solr reverse_proxy
# test me with $ rackup solrrp.ru
# or just do most of this in you web sever config
require 'server'
require 'rack/reverse_proxy'
require 'my_custom_logger'
# catch and log requests
use MyCustomLogger # some code you wrote that logs info about results on the /search* endpoint
use Rack::ReverseProxy do
# Forward only the path /search* to websolr
reverse_proxy /^\/search(.*)$/, 'http://example.com/solr/select$1'
end
# for dedicated solr permiter defense servers, include the following
# if you didn't get redirected, you've come to the wrong place
app = proc do |env|
[ 403, {'Content-Type' => 'text/plain'}, "not authorized" ]
end
run app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment