Skip to content

Commit 67796cb

Browse files
Add files via upload
1 parent 432dac1 commit 67796cb

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

Diff for: proxy/nginx/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM nginx
2+
COPY index.html /usr/share/nginx/html/index.html
3+
COPY default.conf /etc/nginx/conf.d/default.conf

Diff for: proxy/nginx/attack.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
*** Brute Force Python Script ***
3+
4+
- Reference: https://stackoverflow.com/questions/8049520/web-scraping-javascript-page-with-python
5+
6+
"""
7+
8+
import itertools
9+
import urllib2
10+
11+
url = "http://127.0.0.1/rate/3"
12+
13+
14+
for item in itertools.product(range(10), repeat=6):
15+
try:
16+
response = urllib2.urlopen(url)
17+
print "Got response for: "+str(item)
18+
except:
19+
print "Rate limited for: "+str(item)

Diff for: proxy/nginx/default.conf

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Rate limiting
2+
limit_req_zone $request_uri zone=by_uri:10m rate=30r/m;
3+
4+
5+
server {
6+
7+
# Server params
8+
listen 80;
9+
server_name localhost;
10+
11+
# Default Page
12+
location / {
13+
root /usr/share/nginx/html;
14+
index index.html index.htm;
15+
}
16+
17+
# Status page
18+
location /status {
19+
stub_status on;
20+
}
21+
22+
# Only rate limit
23+
location /rate/1 {
24+
limit_req zone=by_uri;
25+
stub_status on;
26+
}
27+
28+
# Rate limit + bursts
29+
location /rate/2 {
30+
limit_req zone=by_uri burst=5;
31+
stub_status on;
32+
}
33+
34+
# Rate limit + bursts + nodelay
35+
location /rate/3 {
36+
limit_req zone=by_uri burst=5 nodelay;
37+
stub_status on;
38+
}
39+
40+
# Error statuc page /50x.html
41+
error_page 500 502 503 504 /50x.html;
42+
location = /50x.html {
43+
root /usr/share/nginx/html;
44+
}
45+
46+
}
47+

Diff for: proxy/nginx/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Nginx Rate Limiting Study

0 commit comments

Comments
 (0)