Skip to content

Commit 8052a3a

Browse files
authored
Merge pull request #1245 from ruby-china/feat/use-caddy
Use Caddy for 3.8.x
2 parents 7925cb3 + 7d50794 commit 8052a3a

File tree

6 files changed

+5
-24
lines changed

6 files changed

+5
-24
lines changed

app/models/setting.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ def legecy_envs
7373
# = System
7474
field :require_restart, default: false, type: :boolean
7575
field :domain, default: (ENV["domain"] || "localhost"), readonly: true
76-
field :https, type: :boolean, default: (ENV["https"] || "true"), readonly: true
7776
field :asset_host, default: (ENV["asset_host"] || nil), readonly: true
7877

7978
# = Basic
@@ -185,7 +184,7 @@ def legecy_envs
185184

186185
class << self
187186
def protocol
188-
self.https? ? "https" : "http"
187+
Rails.env.production? ? "https" : "http"
189188
end
190189

191190
def base_url

config/environments/production.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
config.action_cable.allowed_request_origins = [Setting.cable_allowed_request_origin]
5353

5454
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
55-
config.force_ssl = Setting.https
55+
config.force_ssl = false
5656

5757
# Include generic and useful information about system operation, but avoid logging too much
5858
# information to avoid inadvertent exposure of personally identifiable information (PII).

config/nginx/homeland.conf.erb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,8 @@ log_format timed_combined '$remote_addr - $remote_user [$time_local] '
1515
server {
1616
listen 80 default_server;
1717

18-
<% if ENV['https'] == "true" || ENV["https"] == "1" %>
19-
include /etc/nginx/ssl.conf;
20-
<% end %>
21-
2218
location /nginx_status {
23-
allow 127.0.0.1;
24-
deny all;
25-
stub_status on;
19+
return 200 "ok";
2620
}
2721

2822
root /home/app/homeland/public;
@@ -146,7 +140,6 @@ server {
146140
proxy_http_version 1.1;
147141
proxy_set_header Upgrade $http_upgrade;
148142
proxy_set_header Connection "Upgrade";
149-
proxy_set_header X-Forwarded-Proto $scheme;
150143
proxy_pass http://app_backend;
151144
gzip on;
152145
}

config/nginx/nginx.conf.erb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ worker_processes auto;
33
pid /home/app/pids/nginx.pid;
44
daemon off;
55
load_module modules/ngx_http_image_filter_module.so;
6-
load_module modules/ngx_http_geoip_module.so;
76

87
events {
98
worker_connections <%= ENV["NGINX_WORKER_CONNECTIONS"] || "65535" %>;
@@ -21,10 +20,6 @@ http {
2120
types_hash_max_size 2048;
2221
include /etc/nginx/mime.types;
2322
default_type application/octet-stream;
24-
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
25-
ssl_prefer_server_ciphers on;
26-
# ref: https://wiki.mozilla.org/Security/Server_Side_TLS
27-
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
2823
access_log /home/app/log/nginx-access.log;
2924
error_log /home/app/log/nginx-error.log;
3025
# DO NOT CHANGE THIS

config/nginx/ssl.conf

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/models/setting_test.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,14 @@ class SettingTest < ActiveSupport::TestCase
3535

3636
test "protocol" do
3737
assert_equal "http", Setting.protocol
38-
Setting.stub(:https, true) do
38+
Rails.env.stub(:production?, true) do
3939
assert_equal "https", Setting.protocol
4040
end
4141
end
4242

4343
test "base_url" do
4444
Setting.stubs(:domain).returns("homeland.io")
45-
Setting.stubs(:https).returns(true)
46-
Rails.env.stub(:development?, false) do
45+
Setting.stub(:protocol, "https") do
4746
assert_equal "https://homeland.io", Setting.base_url
4847
end
4948

0 commit comments

Comments
 (0)