|# This code snippet shows how to enable SSL in Sinatra+Thin.|
|class MyThinBackend < ::Thin::Backends::TcpServer|
|def initialize(host, port, options)|
|@ssl = true|
|@ssl_options = options|
|set :environment, :production|
|set :bind, '0.0.0.0'|
|set :port, 443|
|set :server, "thin"|
|class << settings|
|:backend => MyThinBackend,|
|:private_key_file => File.dirname(__FILE__) + "/server.key",|
|:cert_chain_file => File.dirname(__FILE__) + "/server.crt",|
|:verify_peer => false|
|get '/' do|
More generic way is here:
Works great! However, how can I have it send the Access-Control-Allow-Origin header? I'm new to all this ruby stuff, going to go back to googling in the meantime...
edit: got it to work something like this:
get '/blah' do
headers['Access-Control-Allow-Origin'] = '*'
Aside from generating the key, csr, and certificate, is there anything else that needs to be configured (perhaps on the OS level) to get this to work? I can get the sinatra script to execute just fine..it says it's listening on 0.0.0.0:443 but Chrome is saying the site cannot be reached...