Unix/Linux : How to test user agents blocked successfully ?
This is actually a continuation from the tutorial on how to configure nginx to block certain user agents. To test if a web server will response with the configured response status... you can use curl
command.
For example :
curl -I https://www.somewebsite.com
will return HTTP/1.1 200 OK
status
and if the Nginx or Apache web server is configured to block certain user agents .... let say wget
try adding -H 'User-agent: wget'
parameter to the curl command like below
curl -I -H 'User-agent: wget' https://www.somewebsite.com
and it will return HTTP/1.1 403 Forbidden
status
Hope this quick tutorial is helpful for you to check if your Nginx configuration or Apache configuration to block certain user agents is working successfully or not.
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+4.4k Golang : Intercept, inject and replay HTTP traffics from web server
+14.2k Golang : How to convert(cast) IP address to string?
+15.1k Golang : Fix cannot convert buffer (type *bytes.Buffer) to type string error
+5.8k Swift : substringWithRange() function example
+13.8k Golang : Find location by IP address and display with Google Map
+32.6k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+8k Golang : Play .WAV file from command line
+21.1k Golang : Set and Get HTTP request headers example
+18.9k Golang : How to force compile or remove object files first before rebuild?
+13k Golang : Reset buffer example
+10.4k Golang : Get remaining text such as id or filename after last segment in URL path
+11.3k Swift : Convert (cast) Int or int32 value to CGFloat