-
Notifications
You must be signed in to change notification settings - Fork 18
/
nginx_ssl.conf
123 lines (102 loc) · 4.57 KB
/
nginx_ssl.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
server {
server_name up.wiki.yourdomain.com;
listen 80;
listen 443 ssl http2;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
if ($http_x_forwarded_proto = 'http')
{
return 301 $server_name$request_uri;
}
location / {
proxy_pass https://upload.wikimedia.com;
proxy_cookie_domain upload.wikimedia.com up.wiki.yourdomain.com;
proxy_buffering off;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header referer "https://upload.wikimedia.com$request_uri";
}
}
server {
server_name wiki.yourdomain.com;
listen 80;
listen 443 ssl http2;
resolver 8.8.8.8;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
if ($http_x_forwarded_proto = 'http')
{
return 301 $server_name$request_uri;
}
location / {
proxy_pass https://www.wikipedia.com;
proxy_buffering off;
proxy_redirect https://www.wikipedia.com/ http://wiki.yourdomain.com/;
proxy_cookie_domain www.wikipedia.com wiki.yourdomain.com;
proxy_redirect ~^https://([\w\.]+).wikipedia.com/(.*?)$ http://$1.wiki.yourdomain.com/$2;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Accept-Encoding '';
proxy_set_header referer "https://$proxy_host$request_uri";
subs_filter_types text/css text/xml text/javascript application/javascript application/json;
subs_filter .wikipedia.com .wiki.yourdomain.com;
subs_filter //wikipedia.com //wiki.yourdomain.com;
subs_filter upload.wikimedia.com up.wiki.yourdomain.com;
}
}
server {
server_name ~^(?<subdomain>[^.]+)\.wiki\.yourdomain\.com$;
listen 80;
listen 443 ssl http2;
resolver 8.8.8.8;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
if ($http_x_forwarded_proto = 'http')
{
return 301 $subdomain.wiki.yourdomain.com$request_uri;
}
location / {
proxy_pass https://$subdomain.wikipedia.com;
proxy_buffering off;
proxy_redirect https://$subdomain.wikipedia.com/ http://$subdomain.wiki.yourdomain.com/;
proxy_redirect https://$subdomain.m.wikipedia.com/ http://$subdomain.m.wiki.yourdomain.com/;
proxy_cookie_domain $subdomain.wikipedia.com $subdomain.wiki.yourdomain.com;
proxy_redirect ~^https://([\w\.]+).wikipedia.com/(.*?)$ http://$1.wiki.yourdomain.com/$2;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Accept-Encoding '';
proxy_set_header referer "https://$proxy_host$request_uri";
subs_filter_types text/css text/xml text/javascript application/javascript application/json;
subs_filter .wikipedia.com .wiki.yourdomain.com;
subs_filter //wikipedia.com //wiki.yourdomain.com;
subs_filter 'https://([^.]+).wiki' 'http://$1.wiki' igr;
subs_filter upload.wikimedia.com up.wiki.yourdomain.com;
}
}
server {
server_name ~^(?<subdomain>[^.]+)\.m\.wiki\.yourdomain\.com$;
listen 80;
listen 443 ssl http2;
resolver 8.8.8.8;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
if ($http_x_forwarded_proto = 'http')
{
return 301 $subdomain.m.wiki.yourdomain.com$request_uri;
}
location / {
proxy_pass https://$subdomain.m.wikipedia.com;
proxy_buffering off;
proxy_redirect https://$subdomain.m.wikipedia.com/ http://$subdomain.m.wiki.yourdomain.com/;
proxy_cookie_domain $subdomain.m.wikipedia.com $subdomain.m.wiki.yourdomain.com;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Accept-Encoding '';
proxy_set_header referer "https://$proxy_host$request_uri";
subs_filter_types text/css text/xml text/javascript application/javascript application/json;
subs_filter .wikipedia.com .wiki.yourdomain.com;
subs_filter //wikipedia.com //wiki.yourdomain.com;
subs_filter 'https://([^.]+).m.wiki' 'http://$1.m.wiki' igr;
subs_filter upload.wikimedia.com up.wiki.yourdomain.com;
}
}