简体   繁体   中英

Unable to run rails application on puma using ssl

I'm trying to run my rails app on puma in development environment on windows box. Without ssl the application works fine..

But when I try to configure ssl for puma, nothing happens. No error is generated in the log and the web page ( https://localhost:3000/ ) says Secure Connection Failed. Below is the output from command line that shows the server started but nothing happened after that..

E:\ap01\dev\rmmi>foreman start -p 3000
17:19:31 web.1  | started with pid 3016
17:19:34 web.1  | *** SIGUSR2 not implemented, signal based restart unavailable!
17:19:34 web.1  | *** SIGUSR1 not implemented, signal based restart  unavailable!
17:19:34 web.1  | *** SIGHUP not implemented, signal based logs reopening unavailable!
17:19:34 web.1  | Puma starting in single mode...
17:19:34 web.1  | * Version 2.11.2 (ruby 2.0.0-p353), codename: Intrepid Squirrel
17:19:34 web.1  | * Min threads: 5, max threads: 5
17:19:34 web.1  | * Environment: development
17:19:36 web.1  | * Listening on tcp://0.0.0.0:3000
17:19:36 web.1  | * Listening on ssl://127.0.0.1:3000?cert=E:/ap01/OpenSSL-Win32/bin/server.crt&key=E:/ap01/OpenSSL-Win32/bin/server.key
17:19:36 web.1  | Use Ctrl-C to stop

My config/puma.rb file is given below -

path_to_key="E:/ap01/OpenSSL-Win32/bin/server.key"
path_to_cert="E:/ap01/OpenSSL-Win32/bin/server.crt"
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup
port        ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
ssl_bind '127.0.0.1', '3000', { key: path_to_key, cert: path_to_cert }
on_worker_boot do

  ActiveSupport.on_load(:active_record) do
    config = ActiveRecord::Base.configurations[Rails.env] ||
                Rails.application.config.database_configuration[Rails.env]
    config['pool'] = ENV['MAX_THREADS'] || 5
    ActiveRecord::Base.establish_connection(config)
  end
end

The profile for foreman is given below -

 web: bundle exec puma -p $PORT -C config/puma.rb

I've also set config.force_ssl = true in my apps config/application.rb file.

Could you please advise what I'm missing here or doing incorrectly ?. Any pointers will be appreciated

Thanks in Advance!

You aren't doing anything wrong. The browser doesn't trust your local certificate with your localhost, so it will give you a warning.

But you can bypass it using the "Advanced" option on the page (left side bottom) and click proceed to view the ssl version of your application.

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