All threads / How do I configure Rails to use a Proxy URL

Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I configure Rails to use a Proxy URL

Craig Hoffman asked in Servers

Let's say we have a Rails project operating on the domain https://hello.world.com. The way the organization's infrastructure is set up, https://hello.world.com gets proxied into a new URL called - https://my.companies.server.com/hello . When I start the server with Rails s -e production and navigate my browser to https://my.companies.server.com/hello, all the CSS, assets, JS is broken. After some research I changed this config:
config.action_controller.asset_host = 'http://hello.world.com' and the CSS, JS, and assets seem to be working again. Great. One thing that's certainly not right is the links / main navigation (routes). For example, when navigating to any page in the browser, for example, https://my.companies.server.com/about, I get a 404. Seems like there should be a "pass-through" when a request comes in it gets mapped it to https://hello.world/about? Does this make sense? I could use some assistance. What's the best approach here?

My Setup
Rails 6.x.x
Ruby 2.7.x
Nginx

Thanks!

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 52,321+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.