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
+11.3k Golang : Find out mime type from bytes in buffer
+14.1k Golang : Get host name or domain name from IP address
+8.2k Golang : How to unmarshal JSON inner/nested value and assign to specific struct?
+3k Golang : Check if a word is countable or not
+58.4k Golang : Convert HTTP Response body to string
+10.6k Golang : Rename directory
+7k Golang : cannot assign type int to value (type uint8) in range error
+6k Golang : Build and compile multiple source files
+16.6k Golang : Match strings by wildcard patterns with filepath.Match() function
+3.8k Swift : Get substring with rangeOfString() function example
+22.9k Golang : Connect to database (MySQL/MariaDB) server
+2.8k Nginx and PageSpeed build from source CentOS example