Repository navigation
Expand file tree
/
Copy pathengine-ssl.conf
More file actions
82 lines (72 loc) · 3.36 KB
/
Copy pathengine-ssl.conf
File metadata and controls
82 lines (72 loc) · 3.36 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
limit_req_zone $LIMIT_REQ_KEY zone=api:10m rate=5r/s;
limit_req zone=api burst=30 nodelay;
limit_req_status 429;
map $http_origin $cors_allowed_origin {
default "";
"~*$CORS_ALLOWED_ORIGIN_REGEX" $http_origin;
}
# The runtime config is written at boot, so it isn't cached either.
map $uri $runtime_config_cache_control {
default "";
"~^${mount_url}/?env-config\.js$" "no-store, max-age=0";
}
# HTML (e.g. index.html, served for every app route) isn't cached, so a deploy
# can't leave removed chunks referenced. Responses with their own
# Cache-Control keep it.
map "$sent_http_content_type|$sent_http_cache_control" $no_store_cache_control {
"~^text/html[^|]*\|$" "no-store, max-age=0";
default $runtime_config_cache_control;
}
server {
listen $ENGINE_HTTP_PORT;
listen [::]:$ENGINE_HTTP_PORT;
server_tokens off;
return 301 https://$host$request_uri;
}
server {
listen $ENGINE_HTTPS_PORT ssl http2;
listen [::]:$ENGINE_HTTPS_PORT ssl http2;
ssl_certificate /etc/nginx/certs/cert.crt;
ssl_certificate_key /etc/nginx/certs/cert.key;
ssl_protocols TLSv1.2 TLSv1.3;
add_header Strict-Transport-Security "max-age=63072000 " always;
add_header X-Frame-Options "DENY" always;
location $mount_api_url { try_files $uri @app; }
location @app {
include uwsgi_params;
uwsgi_max_temp_file_size 102400m;
uwsgi_pass $uwsgi_pass_url;
# No add_header here: nginx only inherits the server-level add_header
# lines below when a location defines none of its own.
if ($request_method = OPTIONS) {
return 204;
}
}
# Pages load it relative to their <base>, i.e. under the mount path. No
# add_header here either, so it gets the server-level security headers.
location ~ ^${mount_url}/?env-config\.js$ {
alias /tmp/engine-ui-config/env-config.js;
}
location $mount_url {
alias $root_url/;
sub_filter_once on;
sub_filter '<head>' '<head><base href="$BASE_URL">';
try_files $uri $mount_url/index.html;
}
add_header Permissions-Policy "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()" always;
add_header Content-Security-Policy "default-src 'self';script-src 'self' 'sha256-7znq/89hS4wzz2/DYmbizPP16RYMnUCUVak3lYPZl+c=';style-src 'self' 'unsafe-inline';img-src 'self' data:;connect-src 'self' https:;frame-ancestors 'none';form-action 'self';" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Cache-Control $no_store_cache_control always;
add_header Cross-Origin-Resource-Policy "same-origin" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header Cross-Origin-Embedder-Policy "require-corp" always;
add_header Access-Control-Allow-Origin $cors_allowed_origin always;
add_header Access-Control-Allow-Credentials "true" always;
add_header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS" always;
add_header Access-Control-Allow-Headers $http_access_control_request_headers always;
add_header Access-Control-Expose-Headers "Link, x-total, x-total-pages, x-per-page, x-page, x-next-page, x-prev-page, x-next-cursor" always;
add_header Access-Control-Max-Age 1728000 always;
add_header Vary Origin always;
client_max_body_size 0;
server_tokens off;
}