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
+12.8k Golang : Check if a file exist or not
+6.3k Golang : Rot13 and Rot5 algorithms example
+8.1k Random number generation with crypto/rand in Go
+26.5k Golang : Decode/unmarshal unknown JSON data type with map[string]interface
+6.9k Golang : Handle Palindrome string with case sensitivity and unicode
+4.6k Golang : What is StructTag and how to get StructTag's value?
+20.2k SSL : How to check if current certificate is sha1 or sha2
+23.4k Golang : Change file read or write permission example
+7.7k Golang : Find network service name from given port and protocol
+13.5k Golang : Accurate and reliable decimal calculations
+5.5k Golang : How to determine if request or crawl is from Google robots
+3.9k Google : Block or disable caching of your website content