Skip to content

Commit

Permalink
Merge pull request #32 from davidhanley/master
Browse files Browse the repository at this point in the history
Fixing pointer return from header parse. New tests
  • Loading branch information
abedra committed Nov 13, 2015
2 parents c9755d2 + d3dee16 commit 0f77dc3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ http {

location /real {
repsheet_proxy_headers_header "True-Client-IP";
proxy_pass http://127.0.0.1:8888/;
}

location /blacklist {
Expand Down
2 changes: 1 addition & 1 deletion ngx_http_repsheet_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ extract_proxy_header(ngx_http_request_t *r, repsheet_loc_conf_t *loc_conf)
}

if (ngx_strncmp(h[i].key.data, loc_conf->proxy_headers_header.data, h[i].key.len) == 0) {
return h;
return &h[i];
}
}

Expand Down
12 changes: 11 additions & 1 deletion spec/integration/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,22 @@
end

describe "Alternate XFF header" do
it "Properly extracts the alternate header" do

it "Properly extracts & blocks the alternate header when it's blacklisted" do
@redis.set("1.1.1.1:repsheet:ip:blacklisted", "Integration Spec")
http = Curl.get("http://127.0.0.1:8888/real") do |http|
http.headers['True-Client-IP'] = '1.1.1.1'
end
expect(http.response_code).to eq(403)
end

it "doesn't block an unblocked IP with true-client-ip set" do
@redis.set("1.1.1.1:repsheet:ip:blacklisted", "Integration Spec")
http = Curl.get("http://127.0.0.1:8888/real") do |http|
http.headers['True-Client-IP'] = '2.2.2.2'
end
expect(http.response_code).to eq(200)
end

end
end

0 comments on commit 0f77dc3

Please sign in to comment.