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
+8.2k Your page has meta tags in the body instead of the head
+8k Golang : How To Use Panic and Recover
+8.1k Golang : Oanda bot with Telegram and RSI example
+13.9k Golang : Fix cannot use buffer (type bytes.Buffer) as type io.Writer(Write method has pointer receiver) error
+25.9k Mac/Linux and Golang : Fix bind: address already in use error
+4.6k MariaDB/MySQL : How to get version information
+8k Golang : Tell color name with OpenCV example
+19.1k Golang : Delete item from slice based on index/key position
+7.5k Golang : Error reading timestamp with GORM or SQL driver
+11.3k Golang : Handle API query by curl with Gorilla Queries example
+11k Golang : Roll the dice example