Answer the question
In order to leave comments, you need to log in
How to intercept the html generated by the web server before sending?
Hello.
This situation: there are 2 servers on Linux (one with Apache installed, the other with nginx) with a lot of terrible code in languages and frameworks I don't know. Minor edits need to be made.
Please tell me, hypothetically, instead of long and boring picking the insides, is it possible to write a simple script (for example, in python) that would intercept the html generated by the server, find the necessary lines in it and replace it with others? And is it possible to make this script universal for both servers, that is, without preliminary config changes? And which way to look?
Answer the question
In order to leave comments, you need to log in
You can write a proxy server and put it between nginx and apache. There are 5-10 lines of code. I mean, you need an HTTP server that accepts a request, and sends everything that it has received to apache. The response from Apache changes and sends nginx.
You can google.
python proxy server
The best option is of course a module for nginx, but writing your own filter (in this case, you need it) will not be a trivial task.
Look at nginx.org/en/docs/http/ngx_http_sub_module.html and nginx.org/en/docs/http/ngx_http_addition_module.html if not enough, then dig towards nginx.org/en/docs/http/ngx_http_perl_module.html
habrahabr.ru/post/158393 wrote about this here.
There proxy_pass was in a foreign server, you will just have it in your own =)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question