简体   繁体   中英

Can't call my rails server with nginx, got Puma::HttpParserError

I've trouble with my nginx / puma config. When I launch my rails server and try to interact with it, nothing happen and my request is stuck in the browser network. Also, I get this error in my console :

HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>

I'm running ngrok on port 3000, but even when it's not running, I still get the error.

I saw a lot of similar issues (like this one without no answer) but none of them helps me :(

  • I've checked my ssl config with nginx and it's disabled the output of grep -r ssl_protocol /etc/nginx gives

     /etc/nginx/nginx.conf: ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 

    as expected

  • I've cleared my browser cache / history and cookies + restarted my nginx service et rails server

  • config.force_ssl is commented out in my environment/develop.rb (and I'm definively working on this environment) so I guess I'm not connectiong in https

  • I've also commented out the ipv6 conf in /etc/hosts and those two lines are set :

     127.0.0.1 localhost 127.0.0.1 app.example.com 

here is part of my default conf :

server {
    listen              80;
    server_name         app.example.com;
    location / {
        proxy_pass      http://app.example.com:9000;
    }
    location /uploads/ {
        proxy_pass      https://example.s3.amazonaws.com/uploads/;
    }
    location /archives/ {
        proxy_pass      https://example.s3.amazonaws.com/archives/;
    }
    location /container/ {
        proxy_pass      https://example.s3.amazonaws.com;
    }
}

Is there anything I forgot to check here ? I'm not that used to rails, maybe I'm missing something elementary :)

Figured out what happened : I tried to connect my API with an angular front engine, what I've missing here is that I had an oauth conf to add in the angular environment file with https and not just http.

base_url: "http://localhost:3000/",
oauth: "https://localhost:3000/",

It wasn't relative to my rails server either not nginx !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM