-
Notifications
You must be signed in to change notification settings - Fork 59
/
main.nginx.conf
113 lines (90 loc) · 3.55 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
# 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 text/xml text/csv;
location /- {
proxy_pass http://localhost:8005/-;
proxy_redirect off;
proxy_set_header Host $host;
}
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;
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;
}
}
}