-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathmain.nginx.conf
150 lines (125 loc) · 5.09 KB
/
main.nginx.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
# Copyright 2017 ODK Central Developers
# See the NOTICE file at the top-level directory of this distribution and at
# https://github.com/getodk/central-frontend/blob/master/NOTICE.
#
# This file is part of ODK Central. It is subject to the license terms in
# the LICENSE file found in the top-level directory of this distribution and at
# https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central,
# including this file, may be copied, modified, propagated, or distributed
# except according to the terms contained in the LICENSE file.
# This configuration file is for development only. For production, see
# https://github.com/getodk/central.
daemon off;
error_log stderr;
pid ./.nginx/nginx.pid;
events {
}
http {
access_log ./.nginx/nginx-access.log;
client_body_temp_path ./.nginx/client_body_temp;
proxy_temp_path ./.nginx/proxy_temp 1 2;
types {
text/html html htm shtml;
text/css css;
text/xml xml;
application/javascript js;
text/plain txt;
image/png png;
image/x-icon ico;
image/svg+xml svg svgz;
application/font-woff woff;
application/json json;
application/vnd.ms-excel xls;
application/zip zip;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
}
map $sent_http_set_cookie $session_cookie {
~^__Host-(session=.+)$ $1;
}
server {
listen 8989;
server_name localhost;
server_tokens off;
include ./common-headers.nginx.conf;
client_max_body_size 100m;
gzip on;
gzip_vary on;
gzip_min_length 1280;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript application/javascript text/xml text/csv;
# Enketo Configuration.
# Enketo express is traditionally served at /- but with the introduction of ODK Web Forms
# we want old Enketo URLs redirected to a Central frontend page which dynamically decides
# whether to show a WebForm or an iframed Enketo.
#
# Following are the locations that serve a Form and these are redirected to the frontend:
location ~ "^/-/single/(?<enketoId>[a-zA-Z0-9]+)$" {
# Form fill link, public
return 301 "/f/$enketoId$is_args$args";
}
location ~ "^/-/edit/(?<enketoId>[a-zA-Z0-9]+)$" {
# Edit link
return 301 "/f/$enketoId/edit$is_args$args";
}
location ~ "^/-/preview/(?<enketoId>[a-zA-Z0-9]+)$" {
# preview link
return 301 "/f/$enketoId/preview$is_args$args";
}
location ~ "^/-/x/(?<enketoId>[a-zA-Z0-9]+)$" {
# Offline new Submissions - can be public if it has st query parameter
return 301 "/f/$enketoId/offline$is_args$args";
}
location ~ "^/-/(?<enketoId>[a-zA-Z0-9]+)$" {
# Form fill link (non-public), or Draft
return 301 "/f/$enketoId/new$is_args$args";
}
location = /-/single/check-submitted {
alias ./dist/blank.html;
default_type text/html;
}
# For that iframe to work, we'll need another path prefix (enketo-passthrough) under which we can
# reach Enketo — this one will not be intercepted.
location ~ ^/(?:-|enketo-passthrough)(?:/|$) {
rewrite ^/enketo-passthrough(/.*)?$ /-$1 break;
proxy_pass http://localhost:8005;
proxy_redirect off;
proxy_set_header Host $host;
}
# End of Enketo URL redirection.
location ~ ^/v\d {
proxy_pass http://localhost:8383;
proxy_redirect off;
# buffer requests, but not responses, so streaming out works.
proxy_request_buffering on;
proxy_buffering off;
proxy_read_timeout 2m;
# Dev-specific hacks:
# In conjunction with the map{} definition above, remap
# "Set-Cookie: __Host-session=..." to "Set-Cookie: session=..."
#
# 1. Cookies cannot use the "__Host-" prefix in non-HTTPs requests
# see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#cookie_prefixes
# 2. central-backend cookie parsing is relaxed and will consider the
# first cookie ending in "session" to be the session cookie
add_header Set-Cookie $session_cookie;
# re-add common headers after add_header call
include ./common-headers.nginx.conf;
# Trick central-backend from thinking connections are coming
# over HTTPS so that ExpressJS will set "secure" cookies.
proxy_set_header X-Forwarded-Proto https;
}
location = /client-config.json {
include ./common-headers.nginx.conf;
return 200 "{}";
}
location / {
root ./dist;
try_files $uri $uri/ /index.html;
include ./common-headers.nginx.conf;
# We return this header for more files in development than we do in
# production. That's needed because in development, unlike production,
# many file names don't contain hashes.
add_header Cache-Control no-cache;
}
}
}