Skip to content

Instantly share code, notes, and snippets.

@nginx-gists
Created July 27, 2021 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nginx-gists/ecd6c9d12bc0f27c5d041cf1fbc94921 to your computer and use it in GitHub Desktop.
Save nginx-gists/ecd6c9d12bc0f27c5d041cf1fbc94921 to your computer and use it in GitHub Desktop.
Announcing NGINX Plus R11
load_module modules/ngx_http_geoip2_module.so;
var method = "unknown";
var client_messages = 0;
// Called by js_filter directive whenever a packet is processed in the TCP stream
function getSqlMethod(s) {
s.on('upload', function (data, flags) {
client_messages++;
if ( client_messages == 3 ) { // SQL query appears in 3rd client packet
var query_text = data.substr(1,10).toUpperCase();
var methods = ["SELECT", "UPDATE", "INSERT", "SHOW", "CREATE", "DROP"];
var i = 0;
for (; i < methods.length; i++ ) {
if ( query_text.search(methods[i]) > 0 ) {
s.log("SQL method: " + methods[i]); // To error_log [info]
method = methods[i];
s.allow(); // Stop searching
}
}
}
s.allow();
});
}
stream {
log_format custom '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$upstream_session_time $upstream_addr';
#...
ssl_preread on;
# you can also use a more complex map{} to determine the target
proxy_pass $ssl_preread_server_name;
}
# vim: syntax=nginx
@nginx-gists
Copy link
Author

For a discussion of these files, see Announcing NGINX Plus R11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment