Index: nginx.conf ================================================================== --- nginx.conf +++ nginx.conf @@ -1,11 +1,11 @@ # sample nginx config to serve the local site server { listen *:80; listen [fec0::1]:80; - server_name site.to.hijack; + server_name ^(?.+).hijack; access_log /var/log/nginx/site_name.access.log; error_log /var/log/nginx/site_name.error.log debug; expires -1; try_files $uri @break; error_page 404 = @break; @@ -12,17 +12,17 @@ log_not_found off; # autoindex on; location / { if ($request_method != HEAD) { - root /path/to/www/site_name/; + root /path/to/www/$domain; } } location @break { # pointing out where our server listens proxy_pass http://localhost:8008; # saying that we downloading from real site - proxy_set_header Host real.site.name; + proxy_set_header Host $domain; proxy_read_timeout 600; } } Index: samesite.conf ================================================================== --- samesite.conf +++ samesite.conf @@ -2,11 +2,29 @@ # - noetag: ignore etags # - noparts: request full file even for partial request # - proto: protocol, defaults to http # Examples: + +[download.microsoft.com] +noetag: yes [download.windowsupdate.com] noetag: yes -[download.microsoft.com] +[au.download.windowsupdate.com] +noetag: yes + +[ds.download.windowsupdate.com] +noetag: yes + +[www.download.windowsupdate.com] +noetag: yes + +[update.microsoft.com] +noetag: yes + +[fe1.update.microsoft.com] +noetag: yes + +[www.update.microsoft.com] noetag: yes Index: samesite.py ================================================================== --- samesite.py +++ samesite.py @@ -1,12 +1,7 @@ #!/usr/bin/env python3.2 -from __future__ import unicode_literals, print_function - -#import gevent.monkey -#gevent.monkey.patch_all() - import argparse, os parser = argparse.ArgumentParser() parser.add_argument('-c', '--config', dest = 'config', help = 'config file location', metavar = 'FILE', default = 'samesite.conf') args = parser.parse_args() assert os.access(args.config, os.R_OK), "Fatal error: can't read {}".format(args.config) @@ -36,11 +31,10 @@ config[section]['dir'] = thisDir.group(1) if not re.compile('^/(.*)$').match(config[section]['dir']): config[section]['dir'] = cache_dir + os.sep + config[section]['dir'] else: config[section]['dir'] = cache_dir + os.sep + section - if not 'root' in config[section]: config[section]['root'] = section #assert options.port or os.access(options.log, os.R_OK), 'Log file unreadable' @@ -77,10 +71,14 @@ if myPath: my_path = myPath.group(1) else: my_path = self.path + if not config.has_section(self.headers['Host']): + config.add_section(self.headers['Host']) + config[self.headers['Host']]['root'] = self.headers['Host'] + config[self.headers['Host']]['dir'] = cache_dir + os.sep + self.headers['Host'] config_host = config[self.headers['Host']] if config_host['sub'] != None and config_host['strip'] != None and len(config_host['strip']) > 0: string = re.compile(config_host['strip']).sub(config_host['sub'], my_path) my_path = string