R
Railway•11mo ago
Michael

Healthcheck failing - Ruby on Rails

project_id: 5e48166f-cb79-4848-9877-759ac3af182f Hey there 👋, My Rails application deployment fails when the healthcheck path is supplied, however if I remove it and deploy - when I curl or access the path post-deployment there appears to be no issues. There appears no errors or failures during the deploy. ====================== SOLVED ====================== You need to exclude your health check path from your enforced SSL paths, see the below rails docs: https://edgeapi.rubyonrails.org/classes/ActionDispatch/SSL.html Which will tell you to do this if that link is broken:
config.ssl_options = { redirect: { exclude: -> request { /healthcheck/.match?(request.path) } } }
config.ssl_options = { redirect: { exclude: -> request { /healthcheck/.match?(request.path) } } }
No description
No description
No description
Solution:
Hello future traveller. If you find your Ruby on Rails application failing your health check, remember to exclude your healthcheck path from your enforced SSL paths, see the below rails docs: https://edgeapi.rubyonrails.org/classes/ActionDispatch/SSL.html Which will tell you to put something like this in your environment file (e.g. production.rb) if that link is broken: ...
Jump to solution
15 Replies
Percy
Percy•11mo ago
Project ID: 5e48166f-cb79-4848-9877-759ac3af182f
Brody
Brody•11mo ago
can you show me what you have set the path to?
Michael
MichaelOP•11mo ago
I should mention that I have tried both 'up' and '/up'. Neither appears to work In my rails routes, the path is set as so: get "up" => "rails/health#show", :as => :rails_health_check In Railway, I'm primarily setting it to '/up'
Michael
MichaelOP•11mo ago
No description
No description
Brody
Brody•11mo ago
any idea why your app is returning a 404? what do the deploy logs look like?
Michael
MichaelOP•11mo ago
Not sure, when I remove the healthcheck path and do a normal deploy, that path seems perfectly accessible (see the screenshot of the browser). The deploy logs show no sign the requests are even hitting the server
No description
Brody
Brody•11mo ago
have you enabled access logging?
Michael
MichaelOP•11mo ago
My log level in Rails is set to 'info' which means that access requests are logged. Here's a screenshot of me accessing the endpoint when health checks are disabled.
No description
Brody
Brody•11mo ago
do you have some middleware that drops requests that arent from the domain? because the health check is done internally from a local ip address like 192.168.0.102 or 10.0.0.102
Michael
MichaelOP•11mo ago
Hmm an interesting thought. It's a pretty stock-standard rails app - so I don't have anything too fancy. I do enforce access over SSL, and have a middleware that allows clients to pass a header requesting for a response format, but it doesn't require that header. I'll try turning off force SSL and my header middleware and will retry a deploy.
Brody
Brody•11mo ago
oh yeah definitely don’t want that stuff for a health check, especially the force ssl, as railway forces ssl for all public access
Michael
MichaelOP•11mo ago
Nice, that did the trick! I'll confirm whether it was the enforcing of SSL or my header middleware and will get back to this thread with the answer. Will get you a coffee in the meantime
Brody
Brody•11mo ago
thank you so much!
Solution
Michael
Michael•11mo ago
Hello future traveller. If you find your Ruby on Rails application failing your health check, remember to exclude your healthcheck path from your enforced SSL paths, see the below rails docs: https://edgeapi.rubyonrails.org/classes/ActionDispatch/SSL.html Which will tell you to put something like this in your environment file (e.g. production.rb) if that link is broken:
config.ssl_options = { redirect: { exclude: -> request { /healthcheck/.match?(request.path) } } }
config.ssl_options = { redirect: { exclude: -> request { /healthcheck/.match?(request.path) } } }
Brody
Brody•11mo ago
awsome thank you!!
Want results from more Discord servers?
Add your server