-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttps-proxy
More file actions
50 lines (38 loc) · 1.7 KB
/
https-proxy
File metadata and controls
50 lines (38 loc) · 1.7 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
location ~ "\/(?<ip>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/(?<gohost>[^\/]*)(?<path>.*)" {
# kill cache
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
proxy_pass https://$ip/$path;
proxy_set_header Host $gohost;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Accept-Encoding ""; # disallow compression, otherwise the sub_filters don't work
proxy_ssl_name $gohost; # use the to-proxy hostname for SNI as well.
# straight links for this site
sub_filter 'https://$gohost/' 'https://$baseline/$ip/$gohost/';
# forget links back to http, that's stupid
# hrefs
sub_filter 'href="//' 'href="//'; #prevent // from being zapped
sub_filter 'href="/' 'href="https://$baseline/$ip/$gohost/';
# forget links back to http, that's stupid
# for subdomain switches, but breaks a lot of things
#sub_filter 'href="https://' 'href="https://$baseline/$ip/';
#sub_filter 'href=\'https://' 'href=\'https://$baseline/$ip/';
# srcs
sub_filter 'src="/' 'src="https://$baseline/$ip/$gohost/';
# forget links back to http, that's stupid
# for subdomain switches, but breaks a lot of things
#sub_filter 'src="https://' 'src="https://$baseline/$ip/';
#sub_filter 'src=\'https://' 'src=\'https://$baseline/$ip/';
sub_filter_once off;
sub_filter_types *;
# redirects
proxy_redirect https://$gohost https://$baseline/$ip/$gohost;
# no redirects to http, that's stupid
# cookies
proxy_cookie_domain $gohost $baseline;
proxy_cookie_path / /$ip/$gohost/;
#proxy_http_version 1.1; # can't do this, breaks sub_filter...
}