Skip to content

Commit c00475b

Browse files
committed
Switching from builtin ssl using thin to an approach that assumes an ssl proxy server in front. Working nginx example included. This should help keep development simple until you have to go ssl, and then it'll be more like a prod system would look.
1 parent 31d79a3 commit c00475b

File tree

4 files changed

+32
-38
lines changed

4 files changed

+32
-38
lines changed

Gemfile

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ group :development, :test do
4343
gem 'terminal-notifier-guard'
4444
end
4545

46-
gem 'thin' #development ssl support
4746
gem 'whenever', '~> 0.9.0' #cron
4847
gem 'browser', '~> 0.4.0' #device family detection
4948

Gemfile.lock

-7
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@ GEM
5252
coffee-script-source
5353
execjs
5454
coffee-script-source (1.7.0)
55-
daemons (1.1.9)
5655
diff-lcs (1.2.5)
5756
erubis (2.7.0)
58-
eventmachine (1.0.3)
5957
execjs (2.0.2)
6058
ffi (1.9.3)
6159
formatador (0.2.4)
@@ -164,10 +162,6 @@ GEM
164162
sprockets (~> 2.8)
165163
sqlite3 (1.3.8)
166164
terminal-notifier-guard (1.5.3)
167-
thin (1.6.1)
168-
daemons (>= 1.0.9)
169-
eventmachine (>= 1.0.0)
170-
rack (>= 1.0.0)
171165
thor (0.18.1)
172166
thread_safe (0.1.3)
173167
atomic
@@ -205,7 +199,6 @@ DEPENDENCIES
205199
sdoc
206200
sqlite3
207201
terminal-notifier-guard
208-
thin
209202
turbolinks
210203
uglifier (>= 1.3.0)
211204
version_sorter (~> 1.1.0)

Guardfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# A sample Guardfile
22
# More info at https://github.com/guard/guard#readme
33

4-
#guard 'rails', :server => :thin do
5-
# watch('Gemfile.lock')
6-
# watch(%r{^(config|lib)/.*})
7-
#end
4+
guard 'rails' do
5+
watch('Gemfile.lock')
6+
watch(%r{^(config|lib)/.*})
7+
end
88

99

1010
guard :rspec do

ssl/instructions.txt

+28-26
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
1. Generate Key, CSR, then crt. Make sure the FQDN matches the hostname of the computer, or mobile safari will reject it even if you trust the cert at a system level
2-
3-
------
4-
5-
openssl genrsa -out server.key 2048
6-
openssl req -new -key server.key -out server.csr
7-
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
8-
9-
------
10-
11-
2. copy the crt to the public folder
12-
13-
------
14-
15-
cp server.crt ../public/
16-
17-
------
18-
19-
20-
3. start thin from the root directory of shipmate using
21-
22-
------
23-
24-
thin start -p 3001 --ssl --ssl-key-file ssl/server.key --ssl-cert-file ssl/server.crt
25-
26-
------
1+
If you want to test this with iOS 7.1+ apps, you need to front the rails server with an ssl proxy.
2+
3+
Here's a sample nginx server config section
4+
5+
server {
6+
listen 443;
7+
ssl on;
8+
server_name localhost;
9+
10+
#path to your certificate
11+
ssl_certificate /usr/local/etc/nginx/ssl/server.crt;
12+
# path to your ssl key
13+
ssl_certificate_key /usr/local/etc/nginx/ssl/server.key;
14+
15+
# put the rest of your server configuration here.
16+
17+
root /dev/null;
18+
19+
location / {
20+
# set X-FORWARDED_PROTO so ssl_requirement plugin works
21+
proxy_set_header X-FORWARDED_PROTO https;
22+
proxy_set_header X-Real-IP $remote_addr;
23+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
24+
proxy_set_header Host $http_host;
25+
proxy_redirect off;
26+
proxy_pass http://localhost:3000;
27+
}
28+
}

0 commit comments

Comments
 (0)