File tree 4 files changed +30
-2
lines changed
4 files changed +30
-2
lines changed Original file line number Diff line number Diff line change
1
+ if ($http_x_forwarded_proto = "http") {
2
+ rewrite ^(.*)$ https://$http_host$1 permanent;
3
+ }
Original file line number Diff line number Diff line change 45
45
}
46
46
47
47
proxy_set_header Host $http_x_rko_host;
48
+ proxy_set_header X-Forwarded-Proto $http_x_rko_xfp;
48
49
proxy_pass http://localhost:<%= ENV["PORT"] %> ;
49
50
}
50
51
}
@@ -273,6 +274,7 @@ http {
273
274
}
274
275
275
276
location ~ ^/2019(.*) {
277
+ include force_https.conf;
276
278
proxy_pass http://rubykaigi2019.herokuapp.com;
277
279
}
278
280
@@ -291,6 +293,7 @@ http {
291
293
# current rubykaigi
292
294
location = / {
293
295
return 302 http://rubykaigi.org/2018;
296
+ # return 302 https://rubykaigi.org/2019;
294
297
}
295
298
296
299
location ~* /([0-9][0-9][0-9][0-9])?(images|javascripts|stylehseets)/ {
Original file line number Diff line number Diff line change 162
162
end
163
163
end
164
164
165
+ describe "/2019" do
166
+ context "https" do
167
+ let ( :res ) { http_get ( "https://rubykaigi.org/2019" ) }
168
+ it "should be 200" do
169
+ expect ( res . code ) . to eq ( "200" )
170
+ end
171
+ end
172
+
173
+ context "http" do
174
+ let ( :res ) { http_get ( "https://rubykaigi.org/2019" , proto : 'http' ) }
175
+ it "should force https" do
176
+ expect ( res . code ) . to eq ( "301" )
177
+ expect ( res [ "location" ] ) . to eq ( "https://rubykaigi.org/2019" )
178
+ end
179
+ end
180
+ end
181
+
165
182
# TODO consider ja locale case
166
183
end
Original file line number Diff line number Diff line change 3
3
require 'uri'
4
4
5
5
module Helpers
6
- def http_get ( url )
6
+ def http_get ( url , proto : 'https' )
7
7
uri = URI . parse ( url )
8
8
target = URI . parse ( ENV . fetch ( 'TARGET_HOST' , url ) )
9
9
10
10
http = Net ::HTTP . new ( target . host , target . port )
11
11
http . use_ssl = true if target . scheme == 'https'
12
12
13
13
http . start do
14
- http . get ( uri . path , { 'x-rko-host' => uri . host , 'Host' => target . host } )
14
+ headers = {
15
+ 'Host' => target . host ,
16
+ 'x-rko-host' => uri . host ,
17
+ 'x-rko-xfp' => proto ,
18
+ }
19
+ http . get ( uri . path , headers )
15
20
end
16
21
end
17
22
end
You can’t perform that action at this time.
0 commit comments