diff --git a/nginx/nginx.conf b/nginx/nginx.conf index d47e34e15..a2ae47bc1 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -298,7 +298,7 @@ http { # we'll also pluck the low-hanging fruit of restricting to # beats (Go-http-client, see https://github.com/elastic/beats/issues/21975) # and moloch-capture user agents. - if ($http_user_agent !~* ^(arkime|beats|elastic|go-http-client|htpdate|logstash)) { + if ($http_user_agent !~* ^(arkime|beats|elastic|go-http-client|hedgehog|htpdate|logstash)) { return 403; } diff --git a/shared/bin/sensorcommon.py b/shared/bin/sensorcommon.py index bc31eb2a2..4e2148da2 100644 --- a/shared/bin/sensorcommon.py +++ b/shared/bin/sensorcommon.py @@ -131,7 +131,7 @@ def text_from_html(body): ################################################################################################### # test a connection to an HTTP/HTTPS server -def test_connection(protocol="http", host="127.0.0.1", port=80, uri="", username=None, password=None, ssl_verify="full"): +def test_connection(protocol="http", host="127.0.0.1", port=80, uri="", username=None, password=None, ssl_verify="full", user_agent="hedgehog"): status = 400 message = "Connection error" output = [] @@ -149,9 +149,9 @@ def test_connection(protocol="http", host="127.0.0.1", port=80, uri="", username if c: try: if username and password: - c.request('GET', f'/{uri}', headers={ 'Authorization' : 'Basic %s' % b64encode(f"{username}:{password}".encode()).decode("ascii") }) + c.request('GET', f'/{uri}', headers={ 'User-agent': user_agent, 'Authorization' : 'Basic %s' % b64encode(f"{username}:{password}".encode()).decode("ascii") }) else: - c.request('GET', f'/{uri}') + c.request('GET', f'/{uri}', headers={ 'User-agent': user_agent }) res = c.getresponse() status = res.status message = res.reason