Skip to content

Instantly share code, notes, and snippets.

@iagooar
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save iagooar/0dc695ebc4b706fd4909 to your computer and use it in GitHub Desktop.

Select an option

Save iagooar/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
@iagooar
Copy link
Copy Markdown
Author

iagooar commented Jul 24, 2014

Ready for deployment on Heroku.

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