basecamp / easymon

Easy Monitoring
MIT License
205 stars 16 forks source link

Easymon catches any request starting with /up even when it shouldn't #28

Closed mcfearsome closed 5 years ago

mcfearsome commented 5 years ago

I have a site where the following path is being picked up by easymon:

/uppababy-2018-cruz-stroller-emmett-green.html

In the site, this path is a 404, which should then get picked up by our error controller and redirected to a configured destination but it seems like easymon is picking it up before that.

{"method":"GET","path":"/up/pababy-2018-cruz-stroller-emmett-green.html","format":"html","controller":"easymon/checks","action":"show","status":404,"duration":0.92,"view":0.49,"ip":"72.94.148.85","route":"easymon/checks#show","request_id":"7ad5a34f61be33b45a268c486ccd7e0d","source":"app-7f76cd6859-8z497","tags":["request"],"@timestamp":"2019-05-17T14:37:57.568Z","@version":"1"}

It is unclear how the path is changing from /uppababy-2018-cruz-stroller-emmett-green.html to /up/pababy-2018-cruz-stroller-emmett-green.htm

anoldguy commented 5 years ago

Hi Jessie!

The quickest workaround here is to change where Easymon is mounted.

Easymon doesn't care about where it's mounted, we picked /up because it didn't conflict with anything we were doing. So you could easily do something like this in your routes.rb:

mount Easymon::Engine => '/health'
# or
mount Easymon::Engine => '/upz'

I don't have time to dig into this, but feel free to investigate and submit a PR if you solve your issue!

I'm closing this, feel free to re-open with a PR or new info!

mcfearsome commented 5 years ago

In case anyone ends up here:

This seems to be fixed in Rails 5.2 (see https://github.com/rails/rails/pull/35162)

For version prior to 5.2, this is easily worked around by using a constraint:

mount Easymon::Engine => '/up', constraints: { path: /\/up(?:\/([a-zA-Z]*))?$/ }