Custom HTTP protocol response?

J Carter jordanc.carter at outlook.com
Sun Jun 16 01:34:39 UTC 2024


Hello,

On Thu, 13 Jun 2024 16:05:18 +0100
Kirill A. Korinsky <kirill at korins.ky> wrote:

> On Mon, 10 Jun 2024 09:56:05 +0100,
> Martin Kjær Jørgensen via nginx <nginx at nginx.org> wrote:
> > 
> > 
> > Is this possible without hacking nginx sources or manipulative intermediate
> > proxies?
> > 
> 
> As you may see in ngx_http_header_filter_module.c such string is hardcoded.
> 

Indeed. 

I'd reccomend stream njs, with it's filter phase handler, js_filter[1],
if you prefer to perform such intermediary manipulation within nginx
itself.

There is an example of performing HTTP manipulation with js_filter
here[2], albeit for injecting a custom header, but the same approach
would with the 'download' callback. 

The Stream module itself can do TLS offloading[3], now has Virtual
Servers[4], and now has direct pass to http listener feature[5] making
such hacks more workable and efficient :).

[1]https://nginx.org/en/docs/stream/ngx_stream_js_module.html#js_filter
[2]https://github.com/nginx/njs-examples/blob/master/njs/stream/inject_header.js
[3]https://nginx.org/en/docs/stream/ngx_stream_ssl_module.html 
[4]https://nginx.org/en/docs/stream/ngx_stream_core_module.html#server_name
[5]https://nginx.org/en/docs/stream/ngx_stream_pass_module.html


More information about the nginx mailing list