I want to make all generated URLs can start with /sample_1/
as its prefix.
Because the server is running under subfolder,
how could I do on Rails 4.2.4 ? The following routes rules don't generate all paths with the prefix.
I couldn't find any workable solution by Google
routes.rb
Rails.application.routes.draw do
sample_1 = Proc.new do
root 'welcome#category'
end
if ENV['RAILS_RELATIVE_URL_ROOT']
scope ENV['RAILS_RELATIVE_URL_ROOT'] do
sample_1.call
end
else
sample_1.call
end
end
Application.rb
module Sample
class Application < Rails::Application
config.active_record.raise_in_transactional_callbacks = true
config.middleware.use Rack::Deflater
config.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT']
end
end
nginx , the root URL runs flask web server not rails
location /sample_1/ {
rewrite ^/sample_1/(.*)$ /$1 break;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8512;
}
location / {
proxy_pass http://localhost:8006;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}