HTTP parse error, malformed request - Ruby on Rails

后端 未结 5 1723
长情又很酷
长情又很酷 2021-02-19 02:31

I see the following error in Terminal when attempting to run a Ruby on Rails app.

HTTP parse error, malformed request (): #

        
5条回答
  •  萌比男神i
    2021-02-19 02:50

    For those reading this in the future, consider the following:

    1. Did you change your server in your Gemfile. e.g. from Puma to Thin?
    2. Have you set up an SSL certificate?
    3. Are you starting your webserver with SSL certificate flags?
    4. Is SSL turned on in your development/production environment - and what environment are you invoking?

    If you are ok with turning off SSL in your development environment you can do so by going to:

    config/environments/development.rb and configuring:

    config.force_ssl = false

    Here is some code that works for me, using puma, that invokes SSL certification (locally). I have created my certificates and have dumped it in the relevant location:

    rails s -b 'ssl://localhost:3000?key=./.ssl/localhost.key&cert=./.ssl/localhost.crt'

    When I want to run it in a production environment from my PC I using the following:

    rails s -b 'ssl://localhost:3000?key=./.ssl/localhost.key&cert=./.ssl/localhost.crt' -e production

    HTH

提交回复
热议问题