-
Notifications
You must be signed in to change notification settings - Fork 18
/
sony.conf
67 lines (59 loc) · 2.97 KB
/
sony.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
# WARNING ###
# Sony is kinda temperamental at the moment.
# I had problems at my last event with Sony's CDN returning 302 redirects, which breaks the slice request.
# Because of time constraints, I disabled slice (comment out `slice` line, remove `$slice_range` from the
# cache key, remove the `proxy_set_header` line), and enabled 302 following. If you find 302s happening,
# you can do the same. Or, even test combining range and slice at the same time.
server {
listen 80;
server_name *.dl.playstation.net *.dl.playstation.net.edgesuite.net dl.playstation.net dl.playstation.net.edgesuite.net pls.patch.station.sony.com gs2.sonycoment.loris-e.llnwd.net *.dl.playstation.net *.update.playstation.net *.gs2.sonycoment.loris-e.llnwd.net;
sendfile on;
resolver 8.8.8.8 8.8.4.4 ipv6=off;
access_log /var/log/nginx/sony-access.log access;
error_log /var/log/nginx/sony-error.log error;
location / {
slice 1m;
proxy_cache cache;
proxy_cache_key "sony $uri $slice_range"; # $is_args$args
proxy_set_header Range $slice_range;
proxy_hide_header ETag;
proxy_cache_valid 200 206 3000h;
proxy_pass http://$host;
proxy_cache_lock on;
proxy_cache_lock_age 400s;
proxy_cache_lock_timeout 600s;
proxy_ignore_headers Expires Cache-Control;
# These next two lines handle 302 respones that the Sony CDNs
# sometimes return. Without this, the 302 will cause nginx to
# return invalid responses and the PS4 to fail to update.
# TODO: make the config duplication a bit less duplicated.
proxy_intercept_errors on;
error_page 301 302 307 = @handle_redirects;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
location @handle_redirects {
#store the current state of the world so we can reuse it in a minute
# We need to capture these values now, because as soon as we invoke
# the proxy_* directives, these will disappear
set $original_uri $uri;
set $orig_loc $upstream_http_location;
# But we store the result with the cache key of the original request URI
# so that future clients don't need to follow the redirect too
# Everything below here should match the original `location /` block!
# ... EXCEPT the proxy_pass
slice 1m;
proxy_cache cache;
proxy_cache_key "sony $original_uri $slice_range";
proxy_set_header Range $slice_range;
proxy_hide_header ETag;
proxy_cache_valid 200 206 3000h;
proxy_pass $orig_loc;
proxy_cache_lock on; # TODO: will having proxy_lock for the cache key from the original `location /` block break this?
proxy_cache_lock_age 400s;
proxy_cache_lock_timeout 600s;
proxy_ignore_headers Expires Cache-Control;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
}