feat: update nginx generator

This commit is contained in:
fiskhandlarn 2025-11-25 16:46:31 +01:00
commit 2679fcad34

View file

@ -175,7 +175,7 @@ def json_to_htaccess(robot_json):
def json_to_nginx(robot_json): def json_to_nginx(robot_json):
# Creates an Nginx config file. This config snippet can be included in # Creates an Nginx config file. This config snippet can be included in
# nginx server{} blocks to block AI bots. # nginx server{} blocks to block AI bots.
config = f"if ($http_user_agent ~* \"{list_to_pcre(robot_json.keys())}\") {{\n return 403;\n}}" config = f"set $block 0;\n\nif ($http_user_agent ~* \"{list_to_pcre(robot_json.keys())}\") {{\n set $block 1;\n}}\n\nif ($request_uri = \"/robots.txt\") {{\n set $block 0;\n}}\n\nif ($block) {{\n return 403;\n}}"
return config return config