/
nginx.conf.erb
183 lines (162 loc) · 8.14 KB
/
nginx.conf.erb
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
daemon off;
# Heroku dynos have at least 4 cores.
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;
events {
use epoll;
accept_mutex on;
worker_connections <%= ENV['NGINX_WORKER_CONNECTIONS'] || 1024 %>;
}
http {
log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id';
access_log <%= ENV['NGINX_ACCESS_LOG_PATH'] || 'logs/nginx/access.log' %> l2met;
error_log <%= ENV['NGINX_ERROR_LOG_PATH'] || 'logs/nginx/error.log' %>;
# Must read the body in 5 seconds.
client_body_timeout <%= ENV['NGINX_CLIENT_BODY_TIMEOUT'] || 5 %>;
server {
listen <%= ENV["PORT"] %>;
keepalive_timeout 5;
location = /compressiontest/gzip.html {
return 403;
}
location / {
proxy_set_header Accept-Encoding "";
proxy_pass https://www.google.com/;
proxy_cookie_domain .google.com googpxy.herokuapp.com;
proxy_http_version 1.1;
proxy_buffering off;
sub_filter_types *;
sub_filter_once off;
sub_filter 'www.google.com' 'googpxy.herokuapp.com';
sub_filter 'apis.google.com' 'googpxy.herokuapp.com/proxy_apis_google_com';
sub_filter 'ogs.google.com' 'googpxy.herokuapp.com/proxy_ogs_google_com';
sub_filter 'id.google.com' 'googpxy.herokuapp.com/proxy_id_google_com';
sub_filter 'www.gstatic.com' 'googpxy.herokuapp.com/proxy_www_gstatic_com';
sub_filter 'play.google.com' 'googpxy.herokuapp.com/proxy_play_google_com';
sub_filter 'zh.wikipedia.org' 'unipxy.herokuapp.com/proxy/https://zh.wikipedia.org';
sub_filter 'en.wikipedia.org' 'unipxy.herokuapp.com/proxy/https://en.wikipedia.org';
sub_filter 'encrypted-tbn0.gstatic.com' 'googpxy.herokuapp.com/proxy_encrypted-tbn0_gstatic_com';
sub_filter 'encrypted-tbn1.gstatic.com' 'googpxy.herokuapp.com/proxy_encrypted-tbn1_gstatic_com';
sub_filter 'encrypted-tbn2.gstatic.com' 'googpxy.herokuapp.com/proxy_encrypted-tbn2_gstatic_com';
sub_filter 'encrypted-tbn3.gstatic.com' 'googpxy.herokuapp.com/proxy_encrypted-tbn3_gstatic_com';
sub_filter 'webcache.googleusercontent.com' 'googpxy.herokuapp.com/proxy_webcache_googleusercontent_com';
}
location /proxy_play_google_com/ {
proxy_set_header Accept-Encoding "";
proxy_pass https://play.google.com/;
proxy_hide_header Set-Cookie;
proxy_http_version 1.1;
proxy_buffering off;
sub_filter_types *;
sub_filter_once off;
sub_filter 'apis.google.com' 'googpxy.herokuapp.com/proxy_apis_google_com';
sub_filter 'ogs.google.com' 'googpxy.herokuapp.com/proxy_ogs_google_com';
sub_filter 'id.google.com' 'googpxy.herokuapp.com/proxy_id_google_com';
sub_filter 'www.gstatic.com' 'googpxy.herokuapp.com/proxy_www_gstatic_com';
sub_filter 'play.google.com' 'googpxy.herokuapp.com/proxy_play_google_com';
}
location /proxy_www_gstatic_com/ {
proxy_set_header Accept-Encoding "";
proxy_pass https://www.gstatic.com/;
proxy_hide_header Set-Cookie;
proxy_http_version 1.1;
proxy_buffering off;
sub_filter_types *;
sub_filter_once off;
sub_filter 'apis.google.com' 'googpxy.herokuapp.com/proxy_apis_google_com';
sub_filter 'ogs.google.com' 'googpxy.herokuapp.com/proxy_ogs_google_com';
sub_filter 'id.google.com' 'googpxy.herokuapp.com/proxy_id_google_com';
sub_filter 'www.gstatic.com' 'googpxy.herokuapp.com/proxy_www_gstatic_com';
sub_filter 'play.google.com' 'googpxy.herokuapp.com/proxy_play_google_com';
sub_filter 'encrypted-tbn0.gstatic.com' 'googpxy.herokuapp.com/proxy_encrypted-tbn0_gstatic_com';
sub_filter 'encrypted-tbn1.gstatic.com' 'googpxy.herokuapp.com/proxy_encrypted-tbn1_gstatic_com';
sub_filter 'encrypted-tbn2.gstatic.com' 'googpxy.herokuapp.com/proxy_encrypted-tbn2_gstatic_com';
sub_filter 'encrypted-tbn3.gstatic.com' 'googpxy.herokuapp.com/proxy_encrypted-tbn3_gstatic_com';
}
location /proxy_webcache_googleusercontent_com/ {
proxy_set_header Accept-Encoding "";
proxy_pass https://webcache.googleusercontent.com/;
proxy_hide_header Set-Cookie;
proxy_http_version 1.1;
proxy_buffering off;
sub_filter_types *;
sub_filter_once off;
sub_filter 'webcache.googleusercontent.com' 'googpxy.herokuapp.com/proxy_webcache_googleusercontent_com';
}
location /proxy_encrypted-tbn0_gstatic_com/ {
proxy_set_header Accept-Encoding "";
proxy_pass https://encrypted-tbn0.gstatic.com/;
proxy_hide_header Set-Cookie;
proxy_http_version 1.1;
proxy_buffering off;
}
location /proxy_encrypted-tbn1_gstatic_com/ {
proxy_set_header Accept-Encoding "";
proxy_pass https://encrypted-tbn1.gstatic.com/;
proxy_hide_header Set-Cookie;
proxy_http_version 1.1;
proxy_buffering off;
}
location /proxy_encrypted-tbn2_gstatic_com/ {
proxy_set_header Accept-Encoding "";
proxy_pass https://encrypted-tbn2.gstatic.com/;
proxy_hide_header Set-Cookie;
proxy_http_version 1.1;
proxy_buffering off;
}
location /proxy_encrypted-tbn3_gstatic_com/ {
proxy_set_header Accept-Encoding "";
proxy_pass https://encrypted-tbn3.gstatic.com/;
proxy_hide_header Set-Cookie;
proxy_http_version 1.1;
proxy_buffering off;
}
location /proxy_apis_google_com/ {
proxy_set_header Accept-Encoding "";
proxy_pass https://apis.google.com/;
proxy_hide_header Set-Cookie;
proxy_http_version 1.1;
proxy_buffering off;
sub_filter_types *;
sub_filter_once off;
sub_filter 'apis.google.com' 'googpxy.herokuapp.com/proxy_apis_google_com';
sub_filter 'ogs.google.com' 'googpxy.herokuapp.com/proxy_ogs_google_com';
sub_filter 'id.google.com' 'googpxy.herokuapp.com/proxy_id_google_com';
sub_filter 'www.gstatic.com' 'googpxy.herokuapp.com/proxy_www_gstatic_com';
sub_filter 'play.google.com' 'googpxy.herokuapp.com/proxy_play_google_com';
}
location /proxy_ogs_google_com/ {
if ($args ~* (.*)(googpxy.herokuapp.com)(.*)) {
set $args $1www.google.com$3;
rewrite ^.*$ $1 redirect;
}
proxy_set_header Accept-Encoding "";
proxy_pass https://ogs.google.com/;
proxy_hide_header Set-Cookie;
proxy_hide_header X-Frame-Options;
add_header X-Frame-Options 'ALLOW-FROM https://googpxy.herokuapp.com';
proxy_http_version 1.1;
proxy_buffering off;
sub_filter_types *;
sub_filter_once off;
sub_filter 'apis.google.com' 'googpxy.herokuapp.com/proxy_apis_google_com';
sub_filter 'ogs.google.com' 'googpxy.herokuapp.com/proxy_ogs_google_com';
sub_filter 'id.google.com' 'googpxy.herokuapp.com/proxy_id_google_com';
sub_filter 'www.gstatic.com' 'googpxy.herokuapp.com/proxy_www_gstatic_com';
sub_filter 'play.google.com' 'googpxy.herokuapp.com/proxy_play_google_com';
}
location /proxy_id_google_com/ {
proxy_set_header Accept-Encoding "";
proxy_pass https://id.google.com/;
proxy_hide_header Set-Cookie;
proxy_http_version 1.1;
proxy_buffering off;
sub_filter_types *;
sub_filter_once off;
sub_filter 'apis.google.com' 'googpxy.herokuapp.com/proxy_apis_google_com';
sub_filter 'ogs.google.com' 'googpxy.herokuapp.com/proxy_ogs_google_com';
sub_filter 'id.google.com' 'googpxy.herokuapp.com/proxy_id_google_com';
sub_filter 'www.gstatic.com' 'googpxy.herokuapp.com/proxy_www_gstatic_com';
sub_filter 'play.google.com' 'googpxy.herokuapp.com/proxy_play_google_com';
}
}
}