0

I need a domain name (instead of localhost) in my dev environment to be able to test Facebook sign in. So I've added the following to my /etc/hosts file:

127.0.0.1       dev.mydomain.com

But what happens when I restart server and try to access http://dev.mydomain.com:3000 is that if first redirects to https and then returns this in the server log:

2017-05-20 15:23:31 +0200: HTTP parse error, malformed request (): #

2017-05-20 15:23:31 +0200: ENV: {"rack.version"=>[1, 3], "rack.errors"=>#>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"puma 3.8.2 Sassy Salamander", "GATEWAY_INTERFACE"=>"CGI/1.2"}

Any idea what my problem might be, so that I access my app as I successfully can at localhost:3000?

Fellow Stranger
  • 32,129
  • 35
  • 168
  • 232
  • Honestly, what is outlined in the question is what I've tried. This is not my domain of expertise and don't even know where/how to start debugging. – Fellow Stranger May 20 '17 at 14:30
  • The solution depends on how you've configured things... For example simply binding the rails server to localhost may solve it: `rails s -b 0.0.0.0`? – Tom Lord May 20 '17 at 14:34
  • OK tried that now, with no different effect other than `Puma` no more returning the mentioned error message. This thing that there's a `https` redirect - could that be the source of problem? (I don't understand how/why the redirection occurs. In `production.rb` I do have `config.force_ssl = true`, but cannot see that affecting my dev environment.) – Fellow Stranger May 20 '17 at 14:40
  • 1
    [Link1](https://github.com/puma/puma/issues/1128), [Link2](https://github.com/puma/puma/issues/27), [Link3](http://stackoverflow.com/questions/42750685/http-parse-error-malformed-request-ruby-on-rails), [Link4](http://stackoverflow.com/questions/36707585/puma-http-parse-error-malformed-request), ... Do you even need it to be using SSL in development mode? It's more common to only enforce SSL in staging/production environments. – Tom Lord May 20 '17 at 14:40
  • :) Yes, you're correct about SSL. I don't even want it in dev mode. But somehow it's gotten there. – Fellow Stranger May 20 '17 at 14:42
  • 1
    Can you track this down, then? That's not normal behaviour, but I don't know why it's happening. Put your [rails logger level](http://guides.rubyonrails.org/debugging_rails_applications.html#log-levels) to `:debug`, and see if it gives any hints. Grep the source code. Double check that you are running in development environment. Try explicitly turning SSL off. – Tom Lord May 20 '17 at 14:49

1 Answers1

0

You can try the following approaches:

Community
  • 1
  • 1
Tushar Maroo
  • 325
  • 1
  • 5
  • 24