Digital ocean managed deployed rails APP not responding to http (returns 404)

Viewed 210

I followed this 3 parts tutorial and successfully deployed a Rails app in a Managed Digital Ocean App.

Locally, I can use httpie to GET resources and POST to create new users such as:

http :8080/signup name=test email=test@email.com password=foobar password_confirmation=foobar

But, once deployed on digital ocean with at this url with valid TCP health check, I try to create an user (with http/postman):

http mtserver-igkkx.ondigitalocean.app:8080/signup name=test email=test@email.com password=foobar password_confirmation=foobar

and end up with:

HTTP/1.1 301 Moved Permanently
CF-RAY: 6d851c0f7951408d-CDG
Cache-Control: max-age=3600
Connection: keep-alive
Date: Fri, 04 Feb 2022 16:00:02 GMT
Expires: Fri, 04 Feb 2022 17:00:02 GMT
Location: https://mtserver-igkkx.ondigitalocean.app/signup
Server: cloudflare
Transfer-Encoding: chunked
Vary: Accept-Encoding

Assuming I need to prefix the URL with https, i try again with:

http https://mtserver-igkkx.ondigitalocean.app:8080/signup name=test email=test@email.com password=foobar password_confirmation=foobar

And end up with:

http: error: SSLError: HTTPSConnectionPool(host='mtserver-igkkx.ondigitalocean.app', port=8080): Max retries exceeded with url: /signup (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:997)'))) while doing a POST request to URL: https://mtserver-igkkx.ondigitalocean.app:8080/signup

If I try a POST with postman:

POST > mtserver-igkkx.ondigitalocean.app:8080/signup?name=test&email=test@mail.com&password=foobar&password_confirmation=foobar

it returns:

{
    "status": 404,
    "error": "Not Found"
}

While visiting the server URL on '/' it returns a 404 but I assume it's normal as it's only supposed to work in API mode and no route currently handles /.

I'm Looking forward to understand how to handle digital ocean in production to be able to create users on this API through http requests.

1 Answers

For the record, ssl was the problem.

You need to go through the process of adding a SSL certificate through digital ocean so https (and further your web app) works when you query the prefixed url.

This unanswered SO post helped me a lot to figure out the good process.

Related