-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnginx.conf
More file actions
87 lines (75 loc) · 2.5 KB
/
Copy pathnginx.conf
File metadata and controls
87 lines (75 loc) · 2.5 KB
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
worker_processes 1;
daemon off;
error_log stderr error;
events { worker_connections 1024; }
http {
charset utf-8;
log_format cloudfoundry 'NginxLog "$request" $status $body_bytes_sent';
log_format csp_log_format escape=json '{"log":"csp-report", "body":"$request_body"}';
log_format frontend_error_log_format escape=json
'{"log":"frontend-error", "time":"$time_iso8601", '
'"remote_addr":"$remote_addr", "body":"$request_body", "level":"error"}';
access_log /dev/stdout cloudfoundry;
default_type application/octet-stream;
include mime.types;
sendfile on;
tcp_nopush on;
keepalive_timeout 30;
port_in_redirect off;
server {
listen {{port}};
root fecfile-web;
index index.html index.htm Default.htm;
set $nonce $request_id;
set $frontend "{{env "FECFILE_APP_URL"}}";
# Restrict IPs
include blockips.conf;
location = /index.html {
add_header Cache-Control "no-cache, max-age=0, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
add_header Access-Control-Allow-Origin null;
add_header Reporting-Endpoints 'csp-endpoint="$frontend/csp-report"';
add_header Content-Security-Policy "
default-src 'self';
script-src 'self' 'nonce-$nonce';
style-src 'self' 'nonce-$nonce';
connect-src 'self' {{env "FECFILE_API_URL"}};
frame-ancestors 'none';
object-src 'none';
report-to csp-endpoint;
";
sub_filter_once off;
sub_filter_types *;
sub_filter web_app_nonce $nonce;
}
location = /csp-report {
access_log /dev/stdout csp_log_format;
# We have to use proxy_pass so we can log the payload
proxy_pass http://127.0.0.1:{{port}}/csp-report-proxied;
}
location = /csp-report-proxied {
access_log off;
return 204;
}
location = /frontend-error-report {
client_max_body_size 12k;
limit_except POST {
deny all;
}
access_log /dev/stdout frontend_error_log_format;
# We use proxy_pass so nginx logs include request payload.
proxy_pass http://127.0.0.1:{{port}}/frontend-error-report-proxied;
}
location = /frontend-error-report-proxied {
access_log off;
return 200;
}
location / {
error_page 404 = /index.html;
log_not_found on;
add_header Access-Control-Allow-Origin null;
add_header Cache-Control "max-age={{env "CDN_STATIC_ASSET_CACHE_LENGTH_SECONDS"}}, public, immutable";
}
}
}