Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intentionally handling a not found error in pass through request #63

Open
nlively opened this issue Feb 5, 2018 · 0 comments
Open

Intentionally handling a not found error in pass through request #63

nlively opened this issue Feb 5, 2018 · 0 comments

Comments

@nlively
Copy link

nlively commented Feb 5, 2018

I've set up a proxy to redirect a wildcard for my blog. Would like to have some intentional handling around a 404 error if the path I'm passing through doesn't have a destination and gets a 404.

What's the best way to go about this?

config.middleware.insert(0, Rack::ReverseProxy) do
  reverse_proxy /^\/blog(\/?.*)$/, 'http://blog.mysite.com$1'
end

In this example, let's say the following are valid:

  • /blog (goes to http://blog.mysite.com)
  • /blog/my-article (goes to http://blog.mysite.com/my-article)

But the following is NOT valid

  • /blog/does-not-exist (gets a 404 from http://blog.mysite.com/does-not-exist)

I'd like to catch that error and redirect to a page in my Rails app (not something behind the reverse proxy). Is this possible? and how?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant