I want to block certain IP, and replace the Response with Block Page I made by Flask Server in localhost.
How to config that in Nginx.
For Example:
The program 'A' uses requests.get("http://123.123.123.123/GetInfo")
I want to replace the http://123.123.123.123/GetInfo with HTTP://localhost:5000/GetInfo
Is that possible for Nginx?
I can't change the source code of Program 'A'.
And I don't know what others program in my local will access http://123.123.123.123/GetInfo
I've tried the following configuration:
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name 127.0.0.1;
location /GetInfo {
proxy_pass http://127.0.0.1:6000/GetInfo ;
}
}
server {
listen 123.123.123.123:5000;
server_name 123.123.123.123;
rewrite ^/(.*)$ http://127.0.0.1/$1 permanent;
}
}
It doesn't working.