Last active
August 29, 2015 14:04
-
-
Save matisojka/0dc695ebc4b706fd4909 to your computer and use it in GitHub Desktop.
Proxy for separate backend + frontend apps that work together
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
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 |
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
source 'https://rubygems.org' | |
gem 'rack-reverse-proxy', require: 'rack/reverse_proxy' | |
group :development do | |
gem 'foreman' | |
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
web: bundle exec rackup config.ru -p $PORT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ready for deployment on Heroku.