bntjah / lancache

Improve download speeds and reduce strain on your Internet connection at LAN parties. Locally cache game installs and updates from the largest distributors: Steam, RIOT, Blizard, Hirez, Origin, Sony, Microsoft, Tera, GOG, ArenaNetworks, WarGaming, and Uplay. Super easy to setup with auto installer script!
175 stars 44 forks source link

Origin cached files are not served correctly #21

Closed fhibler closed 7 years ago

fhibler commented 7 years ago

Hi, I managed to get lancache up and running without using the lc-installer (currently working on an updated version and will add a pull request soon to incorporate all the changes).

I was able to test it successfully in the following setup:

I was able to verify that it worked for Steam, Blizzard and Microsoft. Unfortunately we haven't used anything else during our small lan party.

For Origin it seems to be a bit different. nginx was able to cache the files correctly, but if another client downloads the same game it caches everything again instead of serving it from the cache. I wonder if the issue belongs to the ?sauth= argument Origin adds to each download. I already checked the nginx config, but that one seems to use the correct argument for proxy_cache_key ($uri instead of $request_uri).

Any ideas?

fhibler commented 7 years ago

Seems I got it working. Has to be changed from http_range to http_slice. Then caching works just as expected. I'll post it in the pull request.

nexusofdoom commented 7 years ago

it is working for me Origin.

note my setup I have a self signed ssl for the domain

computer one downloaded a game and on another computer two downloaded the same game and pulled all contact from the cash.

if you like i can send you my current configs.

[image: Inline image 1]

untitled

nexusofdoom commented 7 years ago

origin

server { listen lancache-origin deferred default; servername origin ;

DNS entries: lancache-origin akamai.cdn.ea.com

    access_log /srv/lancache/logs/lancache-origin-access.log main buffer=128k flush=1m;
    error_log /srv/lancache/logs/lancache-origin-error.log;
    # Origin Node
    include lancache/resolver;
    location / {
            # Currently Origin: * Blocks caching so we have to ignore Expires and Cache-Control. * Puts sauth=<authkey> in the query string so we use $uri
            # instead of $request_uri
            #   in the cache key. * Uses a single archive file with range requests and refuses requests to download the entire file. To combat this we
            #pass-through the Range headers and include the range to the cache key and allow caching of 206 responses. Eproxy_ignore_headers Expires
            #Cache-Control; proxy_set_header Range $http_range; proxy_set_header If-Range $http_if_range; proxy_cache_key "$server_name$uri $http_range";
            #proxy_cache_valid 206 90d; proxy_read_timeout 150;
            # Use Origin cache proxy_cache origin; include lancache/proxy-cache;

            # Request Slicing

set $no_cache ""; if ($request_uri ~* "/(Origin-Client-Download/origin/live/)") { set $no_cache "1"; } proxy_no_cache $no_cache; proxy_cache_bypass $no_cache;

# Supported in nginx 1.9.8
slice 1m;
# Cache Location
proxy_cache origin;
# Cache Settings
proxy_bind x.x.x.x;
proxy_ignore_headers Expires Cache-Control;
proxy_cache_key $uri$slice_range;
proxy_cache_valid 200 206 120d;
proxy_set_header Range $slice_range;
# Use proxy_cache method
include lancache/proxy-cache;
#include lancache/proxy-pass;

    }

}

fhibler commented 7 years ago

The slice config indeed was the fix. This was not in the Repo yet thou :)

fhibler commented 7 years ago

@nexusofdoom I see you are excluding the client from caching. Is that really a good idea or would it be better to set a value of 3h or so before revalidating? The client can also easily have 100+M.

nexusofdoom commented 7 years ago

what would you have me change and test out?

fhibler commented 7 years ago

@nexusofdoom I am just wondering if it makes sense to have some kind of "short term caching with revalidation" for the clients. What's your opinion on it?

nexusofdoom commented 7 years ago

the client still has issue updating with my config so off and on I download the full installer to get it updated. the game files cache works fine its just the client does not update I have to update manually

fhibler commented 7 years ago

I see ... the origin client downloader uses https, which I actually route through sniproxy, so it's not being cached anyways. Just confirmed this with a tcpdump.

bntjah commented 7 years ago

@nexusofdoom @fhibler updated the conf of Origin; if any other fixes you see; please feel free to post here. Haven't really had the time to further test / improve the LC but any help is always welcome :-)