Skip to content

Commit

Permalink
Use SSL/TLS in development
Browse files Browse the repository at this point in the history
  • Loading branch information
dentarg committed Sep 24, 2021
1 parent e66200a commit 1eea08b
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 3 deletions.
1 change: 1 addition & 0 deletions .foreman
@@ -1 +1,2 @@
formation: development=1
port: 8080
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -27,6 +27,7 @@ gem 'pry'

group :development do
gem 'foreman'
gem 'localhost'
end

group :test do
Expand Down
4 changes: 3 additions & 1 deletion Gemfile.lock
Expand Up @@ -34,6 +34,7 @@ GEM
domain_name (~> 0.5)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
localhost (1.1.9)
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
Expand Down Expand Up @@ -145,6 +146,7 @@ DEPENDENCIES
github-markup
haml
html-pipeline
localhost
minitest
octokit
pg
Expand All @@ -170,4 +172,4 @@ RUBY VERSION
ruby 2.6.8p205

BUNDLED WITH
2.2.23
2.2.25
1 change: 1 addition & 0 deletions Procfile
@@ -1 +1,2 @@
web: bundle exec puma -C config/puma.rb
development: bundle exec puma -b tcp://localhost:$(($PORT-100)) -b ssl://localhost:$(($PORT-100-1000))
17 changes: 15 additions & 2 deletions config.ru
Expand Up @@ -16,8 +16,21 @@ end

require_relative 'config/app'

unless development? || test?
use Rack::SSL
# SSL/TLS in development on port $PORT-1000 (port $PORT will redirect there)
# https://github.com/socketry/localhost
require 'localhost' if development?

unless test?
options = if development?
# Subtract 100 because of foreman offset bug:
# https://github.com/ddollar/foreman/issues/714
# https://github.com/ddollar/foreman/issues/418
{ host: "localhost:#{ENV.fetch('PORT').to_i - 100 - 1000}" }
else
{}
end

use Rack::SSL, options
end

use Rack::Session::Cookie,
Expand Down
14 changes: 14 additions & 0 deletions test/integration/app_boot_test.rb
Expand Up @@ -25,4 +25,18 @@ def test_app_boot
WaitForIt.new(command_from_procfile, options) do |spawn|
end
end

def test_app_development_boot
options = {
timeout: 5,
wait_for: /Worker.+booted/,
}

ClimateControl.modify(RACK_ENV: "development", PORT: "5000") do
command = command_from_procfile(worker: "development")

WaitForIt.new(command, options) do |spawn|
end
end
end
end
Binary file added vendor/cache/localhost-1.1.9.gem
Binary file not shown.

0 comments on commit 1eea08b

Please sign in to comment.