When I using this gem, I found out it might get the wrong response from server(rails version 6.1..6.1).
e.q.: I kept made 2 request calling, A is http://127.0.0.1/?value=dummy1
and B is http://127.0.0.1/?value=dummy2
Assume the api is very simple that only return the value sent.
That means A should get {value: “dummy1”}, B should get {value: “dummy2”}
Sometimes, B would get {value: “dummy1”}.
After I checked the project setting, I found out the problem is config.middleware.insert_before(Rails::Rack::Logger, RemoteIpProxyScrubber.filter_middleware, scrubbed_ips)
.
That is, if I marked this code, the problem solved. However, I still need this gem help me to scrub the ip.
here is my code in config/application.rb
# Load the list of scrubbed IPs from the YAML file
scrubbed_ips = JSON.parse(File.read(Rails.root.join('config', 'initializers', 'scrubbed_ips.json')))['scrubbed_ips']
config.middleware.insert_before(Rails::Rack::Logger, RemoteIpProxyScrubber.filter_middleware, scrubbed_ips)
config.middleware.insert_before(Rails::Rack::Logger, RemoteIpProxyScrubber.patched_logger)
config.middleware.delete(Rails::Rack::Logger)
and the value in scrubbed_ips.json would be like:
{
"scrubbed_ips": [
"1.1.1.0/26",
"2.2.2.0/26",
.
.
.
]
}
Once the scrubbed_ips
increased, the error rate would increased.
Also, once the api spent more time, the error rate would increased.
I had made a small test. Even if I only put 2 IPs in scrubbed_ips, there are also some errors might occurred.
Is there someone met the some bugs like this?
2