mirror of
https://github.com/ai-robots-txt/ai.robots.txt.git
synced 2025-12-29 12:18:33 +01:00
feat: update nginx generator
This commit is contained in:
parent
ef8eda4fe6
commit
2679fcad34
1 changed files with 6 additions and 6 deletions
|
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue