Reputation: 148
Issue: I need to modify the response which is HTML. Need to inject data attribute into the response body.
The data attribute value would be the query param/post params.
Having Nginx as a webserver. How can we achieve this?
I checked already the nginx+lua. But is there any other approach? Also would SSI solve this problem? If yes then how can we get the query param and post value from nginx
Upvotes: 0
Views: 1040
Reputation: 14381
You are exposing yourself to XSS attacks but it should be possible with the ngx_http_sub_module. To access query string parameter foo
use $arg_foo
.
So something like this:
location / {
sub_filter '##NAME##' $arg_foo;
}
If you call your site with ?foo=Hello
it will replace ##NAME##
in your HTML with Hello
.
In general however it's a terrible idea to let outside things (like querystring parameters) directly pass into your HTML!
Upvotes: 0