Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Puma doesn't start in ssl mode #25700

Closed
janwendt opened this issue Jul 5, 2016 · 4 comments
Closed

Puma doesn't start in ssl mode #25700

janwendt opened this issue Jul 5, 2016 · 4 comments

Comments

@janwendt
Copy link

janwendt commented Jul 5, 2016

I have added this one to my puma.rb

ssl_bind '0.0.0.0', '3000', {
  key: 'config/ssl-certificate/my-server.key.pem',
  cert: 'config/ssl-certificate/my-server.crt.pem'
}

and rails s doesn't start puma in ssl mode.
puma -C config/puma.rb works just fine!!!

@schneems
Copy link
Member

schneems commented Jul 5, 2016

This is related to #24435 and puma/puma#939.

Here is the issue. Puma favors config you pass in directly over config in your puma.rb. For example if you have

port 3001

and you run

$ puma --port 5001

Then 5001 will win. Why does this matter? Rails allows you to run $ rails server -p 5001 however it also specifies a default port of 3000 when running $ rails server. Puma doesn't know the difference between the default passed in and an explicit user supplied argument. So it always uses what it thinks is the "passed in" argument which in this case would be using a port of 3000 even though it's only the default. This takes precedence over your connection config since all that method does is build a port to connect to:

      def ssl_bind(host, port, opts)
        o = [
          "cert=#{opts[:cert]}",
          "key=#{opts[:key]}"
        ]

        @options[:binds] << "ssl://#{host}:#{port}?#{o.join('&')}"
      end

It works with the $ puma command (btw it auto reads config/puma.rb no need to specifiy the config file) because there is no provided default port.

The answer is to not use the $ rails s command.

@daniel-g
Copy link

This problem is really weird. One of my rails apps reads the config file, and one does not.

@daniel-g
Copy link

@janwendt it worked for me using these versions:

  • rails (5.0.1)
  • puma (3.7.0)

@rails-bot rails-bot bot added the stale label May 23, 2017
@rails-bot
Copy link

rails-bot bot commented May 23, 2017

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 5-1-stable branch or on master, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants