Add the following fields to the configuration file:
Server {
# Block SQL injections for SQL Injection
Set $ block_ SQL _injections 0;
If ($ query_string ~ "Union. * select. * \ (") {
Set $ block_ SQL _injections 1;
}
If ($ query_string ~ "Union. * all. * select .*"){
Set $ block_ SQL _injections 1;
}
If ($ query_string ~ "Concat. * \ (") {
Set $ block_ SQL _injections 1;
}
If ($ block_ SQL _injections = 1 ){
Return 444;
}
# Disable file injection
Set $ block_file_injections 0;
If ($ query_string ~ "[A-zA-Z0-9 _] = http ://"){
Set $ block_file_injections 1;
}
If ($ query_string ~ "[A-zA-Z0-9 _] = (\.\.//?) + "){
Set $ block_file_injections 1;
}
If ($ query_string ~ "[A-zA-Z0-9 _] =/([a-z0-9 _.] //?) + "){
Set $ block_file_injections 1;
}
If ($ block_file_injections = 1 ){
Return 444;
}
# Preventing overflow attacks
Set $ block_common_exploits 0;
If ($ query_string ~ "(<| % 3C). * script. * (> | % 3E )"){
Set $ block_common_exploits 1;
}
If ($ query_string ~ "GLOBALS (= | \ [| \ % [0-9A-Z] {0, 2 })"){
Set $ block_common_exploits 1;
}
If ($ query_string ~ "_ REQUEST (= | \ [| \ % [0-9A-Z] {0, 2 })"){
Set $ block_common_exploits 1;
}
If ($ query_string ~ "Proc/self/environ "){
Set $ block_common_exploits 1;
}
If ($ query_string ~ "MosConfig _ [a-zA-Z _] {} (=|\% 3D )"){
Set $ block_common_exploits 1;
}
If ($ query_string ~ "Base64 _ (en | de) code \(.*\)"){
Set $ block_common_exploits 1;
}
If ($ block_common_exploits = 1 ){
Return 444;
}
# Disable the spam Field
Set $ block_spam 0;
If ($ query_string ~ "\ B (ultram | unicauca | valium | viagra | vicodin | xanax | ypxaieo) \ B "){
Set $ block_spam 1;
}
If ($ query_string ~ "\ B (erections | hoodia | huronriveracres | impotence | levitra | libido) \ B "){
Set $ block_spam 1;
}
If ($ query_string ~ "\ B (ambien | blue \ spill | ciill | cocaine | ejaculation | erectile) \ B "){
Set $ block_spam 1;
}
If ($ query_string ~ "\ B (lipitor | phentermin | pro [sz] ac | sandyauer | tramadol | troyhamby) \ B "){
Set $ block_spam 1;
}
If ($ block_spam = 1 ){
Return 444;
}
# Disable user-agents
Set $ block_user_agents 0;
# Don't disable wget if you need it to run cron jobs!
# If ($ http_user_agent ~ "Wget "){
# Set $ block_user_agents 1;
#}
# Disable Akeeba Remote Control 2.5 and earlier
If ($ http_user_agent ~ "Indy Library "){
Set $ block_user_agents 1;
}
# Common bandwidth hoggers and hacking tools.
If ($ http_user_agent ~ "Libwww-perl "){
Set $ block_user_agents 1;
}
If ($ http_user_agent ~ "GetRight "){
Set $ block_user_agents 1;
}
If ($ http_user_agent ~ "GetWeb !") {
Set $ block_user_agents 1;
}
If ($ http_user_agent ~ "Go! Zilla "){
Set $ block_user_agents 1;
}
If ($ http_user_agent ~ "Download Demon "){
Set $ block_user_agents 1;
}
If ($ http_user_agent ~ "Go-Ahead-Got-It "){
Set $ block_user_agents 1;
}
If ($ http_user_agent ~ "TurnitinBot "){
Set $ block_user_agents 1;
}
If ($ http_user_agent ~ "GrabNet "){
Set $ block_user_agents 1;
}
If ($ block_user_agents = 1 ){
Return 444;
}
}
Description: SQL Injection, overflow attacks, and spam protection are implemented by disabling the fields contained in the URL. Please add them as needed.
444 is returned, which does not respond to the client at all, saving system resources much more than 403.