forked from 18F/18f.gsa.gov
-
Notifications
You must be signed in to change notification settings - Fork 0
/
18f-site.conf
253 lines (203 loc) · 6.84 KB
/
18f-site.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# nginx configuration for 18f.gsa.gov, and its staging site, staging.18f.us.
#
# Also handles forwarding /deploy webhooks for GitHub, so that pushes to
# the `staging` and `production` branches deploy to the staging and
# production sites, respectively. See the deploy/ dir in this repo for details.
#
# For our TLS configuration (ssl.rules), please see
# https://github.com/18F/tls-standards/blob/master/configuration/nginx/ssl.rules
#
# HSTS is handled slightly differently for the root 18f.us redirect (it does not
# include subdomains, as we use that domain for all kinds of testing), so each
# domain has to either include hsts.rules or hsts-no-subdomains.rules.
#
# NOTE: This nginx configuration is not currently synced automatically to version
# control, so the deployed version may drift out of sync, though we'll try
# not to let that happen.
# production HTTPS server
# production site comes first so that non-SNI clients get this one
server {
listen 443 ssl spdy;
server_name 18f.gsa.gov;
ssl_certificate /etc/nginx/ssl/keys/18f.gsa.gov-chained.crt;
ssl_certificate_key /etc/nginx/ssl/keys/18f.gsa.gov.key;
include ssl/ssl.rules;
include ssl/hsts.rules;
add_header X-Government-Innovation Disrupted;
error_page 404 /404/index.html;
error_page 500 /500/index.html;
location / {
root /home/site/production/current/_site;
default_type text/html;
include cors.rules;
}
location /dashboard {
root /home/site/production/dashboard/_site;
default_type text/html;
include cors.rules;
}
location /hub {
root /home/site/production/hub/_site_public;
index index.html api.json;
default_type text/html;
include cors.rules;
}
# proxy to hydra, cover up for their lack of HTTPS
location /listserv {
proxy_pass http://hydra.gsa.gov/cgi-bin/listserv.pl;
proxy_http_version 1.1;
proxy_redirect off;
# *don't* forward hostname or protocol
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_max_temp_file_size 0;
proxy_connect_timeout 10;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
# production hook runs on port 4000
location /deploy {
proxy_pass http://localhost:4000/;
proxy_http_version 1.1;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_max_temp_file_size 0;
proxy_connect_timeout 10;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
location /dashboard/deploy {
proxy_pass http://localhost:4001/;
proxy_http_version 1.1;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_max_temp_file_size 0;
proxy_connect_timeout 10;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
# Redirect /code/<project> to the corresponding GitHub page
location /code {
rewrite ^/code/(.*)$ https://github.com/18F/$1 redirect;
return 403;
}
access_log /home/site/production/nginx_access.log main;
error_log /home/site/production/nginx_error.log;
}
# staging site, https://staging.18f.us
# staging site comes first so that it intercepts other domain names too
server {
listen 443 ssl spdy;
server_name default_server;
server_name staging.18f.us;
# wildcard cert
ssl_certificate /etc/nginx/ssl/keys/star.18f.us-chain.crt;
ssl_certificate_key /etc/nginx/ssl/keys/star.18f.us.key;
include ssl/ssl.rules;
include ssl/hsts.rules;
error_page 404 /404/index.html;
error_page 500 /500/index.html;
location / {
root /home/site/staging/current/_site;
default_type text/html;
include cors.rules;
}
location /dashboard {
root /home/site/staging/dashboard/_site;
include cors.rules;
}
# production hook runs on port 3000
location /deploy {
proxy_pass http://localhost:3000/;
proxy_http_version 1.1;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_max_temp_file_size 0;
proxy_connect_timeout 10;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
location /dashboard/deploy {
proxy_pass http://localhost:3001/;
proxy_http_version 1.1;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_max_temp_file_size 0;
proxy_connect_timeout 10;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
# proxy to hydra, cover up for their lack of HTTPS
location /listserv {
proxy_pass http://hydra.gsa.gov/cgi-bin/listserv.pl;
proxy_http_version 1.1;
proxy_redirect off;
# *don't* forward hostname or protocol
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_max_temp_file_size 0;
proxy_connect_timeout 10;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
access_log /home/site/staging/nginx_access.log main;
error_log /home/site/staging/nginx_error.log;
}
# redirect http to https:// in both cases
server {
listen 80;
server_name 18f.gsa.gov;
server_name www.18f.gsa.gov;
return 301 https://18f.gsa.gov$request_uri;
}
server {
listen 80;
server_name staging.18f.us;
return 301 https://staging.18f.us$request_uri;
}
# redirect 18f.us and 18f.gov to our homepage
server {
listen 80;
server_name 18f.us;
server_name www.18f.us;
server_name 18f.gov;
server_name www.18f.gov;
add_header Cache-Control no-cache;
return 301 https://18f.gsa.gov$request_uri;
}
# also redirect https://18f.us to our homepage
server {
listen 443 ssl spdy;
server_name 18f.us;
server_name www.18f.us;
ssl_certificate /etc/nginx/ssl/keys/star.18f.us-chain.crt;
ssl_certificate_key /etc/nginx/ssl/keys/star.18f.us.key;
include ssl/ssl.rules;
include ssl/hsts-no-subdomains.rules;
add_header Cache-Control no-cache;
return 301 https://18f.gsa.gov$request_uri;
}
# also redirect https://18f.gov to our homepage
server {
listen 443 ssl spdy;
server_name 18f.gov;
server_name www.18f.gov;
ssl_certificate /etc/nginx/ssl/keys/www.18f.gov.chained.crt;
ssl_certificate_key /etc/nginx/ssl/keys/www.18f.gov.key;
include ssl/ssl.rules;
include ssl/hsts-no-subdomains.rules;
add_header Cache-Control no-cache;
return 301 https://18f.gsa.gov$request_uri;
}