Here's the problem:
I have two PCs. One is using Windows 10 and the other is using Linux. The Windows PC is requesting a file from a third party server. I need to replace it with my file on the fly. Maybe using the second pc as a proxy and something like Man in the middle. I could put my Linux-PC ip in Hosts, but I only need to replace one file, I shouldn't change all other requests.
As an example: Win-Pc asks the server for a file. Linux-PC acts as a proxy. Somehow linux-pc changes the requested file to my file (without changing its name and extension) and sends it to win-pc saying it's the original file.
The question is how to make linux-pc work as a proxy and how to replace the file
PS Both pc are at my place and I have full access to them. That is, I can completely change the hosts and have administrator rights
suppose you want to substitute file matching to URL http://zzz.com/123.txt
you need to
server {
listen 80;
server_name zzz.com;
root /static-files;
location / {
try_files $uri $uri/ @server;
}
location @server {
proxy_pass http://zzz.com;
}
}
192.168.0.123 zzz.com
with such config nginx will intercepts queries matching files located in "root" directory (and serve local copies of those files) and pass through other requests to the real server
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.