-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.conf
More file actions
64 lines (55 loc) · 2.57 KB
/
Copy pathdefault.conf
File metadata and controls
64 lines (55 loc) · 2.57 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
map $sent_http_content_type $addin_cache_control {
default "no-cache, must-revalidate";
~*text/html "no-cache, must-revalidate";
~*application/xml "no-cache, must-revalidate";
~*application/javascript "public, max-age=300, must-revalidate";
~*text/css "public, max-age=300, must-revalidate";
~*image/ "public, max-age=86400";
~*font/ "public, max-age=86400";
~*application/wasm "public, max-age=86400";
}
# Origin allowlist for CORS. The add-in's own assets are served same-origin
# inside the Office iframe, so most requests need no CORS at all; the entries
# below cover the Microsoft origins that legitimately fetch add-in assets
# cross-origin (Office.js CDN and the Outlook hosts). The request Origin is
# echoed back only when it is on the allowlist — any other origin gets an
# empty value, and nginx then omits the Access-Control-Allow-Origin header
# entirely, so arbitrary sites cannot read responses cross-origin.
map $http_origin $addin_cors_origin {
default "";
"https://appsforoffice.microsoft.com" $http_origin;
"https://outlook.office.com" $http_origin;
"https://outlook.office365.com" $http_origin;
"https://outlook.live.com" $http_origin;
}
server {
listen 80 default_server;
server_name _;
root /usr/share/nginx/html;
index taskpane.html;
# Office hosts the add-in inside an iframe — do NOT set X-Frame-Options.
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Cache-Control $addin_cache_control always;
# Restrict CORS to the allowlisted Office/Outlook origins (see the
# $addin_cors_origin map above). For any other origin the value is empty
# and nginx skips the header, so only the trusted Microsoft origins can
# read add-in responses cross-origin. Vary: Origin keeps caches from
# serving one origin's CORS response to another.
add_header Access-Control-Allow-Origin $addin_cors_origin always;
add_header Vary Origin always;
location = /health {
access_log off;
add_header Content-Type text/plain;
return 200 "ok\n";
}
location / {
try_files $uri $uri/ =404;
}
# The manifest is served as XML; some clients are picky about the type.
location = /manifest.xml {
default_type application/xml;
}
# Hide nginx version
server_tokens off;
}