Skip to content

Commit b9785c1

Browse files
committed
Set original regex. Breaks Baidu.
Need to figure out a better way to do this, but for now move back to the old way because the new regex was capturing too much.
1 parent 671c449 commit b9785c1

File tree

3 files changed

+4
-25
lines changed

3 files changed

+4
-25
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ bot_verifier_redis_read_timeout
123123

124124
**syntax:** *bot_verifier_redis_read_timeout* <int>
125125

126-
**default:** *5*
126+
**default:** *10*
127127

128128
**context:** *location*
129129

ngx_http_bot_verifier_module.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ ngx_http_bot_verifier_module_create_loc_conf(ngx_conf_t *cf)
217217
ngx_str_t identifier_pattern = ngx_string("google|bing|yahoo|baidu|yandex");
218218
conf->identifier_regex = make_regex(cf->pool, &identifier_pattern);
219219

220-
// ngx_str_t domain_pattern = ngx_string("[^.]*\\.[^.]{2,3}(?:\\.[^.]{2,3})?$");
221-
ngx_str_t domain_pattern = ngx_string("\\.(.*)");
220+
ngx_str_t domain_pattern = ngx_string("[^.]*\\.[^.]{2,3}(?:\\.[^.]{2,3})?$");
221+
// ngx_str_t domain_pattern = ngx_string("\\.(.*)");
222222
conf->domain_regex = make_regex(cf->pool, &domain_pattern);
223223

224224
return conf;

t/enabled.t

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ location = /t {
9696
"GET /t HTTP/1.1\r
9797
Host: 127.0.0.1\r
9898
Connection: close\r
99-
X-Forwarded-For: 157.55.33.18\r
99+
X-Forwarded-For: 65.52.104.9\r
100100
User-Agent: Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)\r
101101
\r
102102
"
@@ -143,24 +143,3 @@ User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.h
143143
\r
144144
"
145145
--- error_code: 403
146-
147-
=== TEST 8: baidu agent provided, identified, valid (200)
148-
--- config
149-
location = /t {
150-
bot_verifier on;
151-
bot_verifier_redis_host localhost;
152-
bot_verifier_redis_port 6379;
153-
bot_verifier_redis_connection_timeout 10;
154-
bot_verifier_redis_read_timeout 10;
155-
bot_verifier_redis_expiry 3600;
156-
echo 'test';
157-
}
158-
--- raw_request eval
159-
"GET /t HTTP/1.1\r
160-
Host: 127.0.0.1\r
161-
Connection: close\r
162-
X-Forwarded-For: 180.76.15.5\r
163-
User-Agent: Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)\r
164-
\r
165-
"
166-
--- error_code: 200

0 commit comments

Comments
 (0)