Skip to content

Instantly share code, notes, and snippets.

@matisojka
Last active August 29, 2015 14:04
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 matisojka/0dc695ebc4b706fd4909 to your computer and use it in GitHub Desktop.
Save matisojka/0dc695ebc4b706fd4909 to your computer and use it in GitHub Desktop.
Proxy for separate backend + frontend apps that work together
require 'rack/reverse_proxy'
use Rack::ReverseProxy do
reverse_proxy_options preserve_host: true, matching: :first
reverse_proxy '/api', ENV['API_URL'] || 'http://localhost:3000/api'
reverse_proxy '/', ENV['STATIC_URL'] || 'http://localhost:3333'
end
app = proc do |env|
[ 200, {'Content-Type' => 'text/plain'}, 'b' ]
end
run app
source 'https://rubygems.org'
gem 'rack-reverse-proxy', require: 'rack/reverse_proxy'
group :development do
gem 'foreman'
end
web: bundle exec rackup config.ru -p $PORT
@matisojka
Copy link
Author

Ready for deployment on Heroku.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment