diff --git a/defaults/main.yml b/defaults/main.yml index 6313fd0..232e302 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -149,10 +149,36 @@ nginx_robots_disallow_everything: false nginx_robots_enable_crawl_delay: false nginx_robots_crawl_delay: 10 nginx_robots_disallowed_useragent_list: - - SemrushBot - - SemrushBot-SA - - Yandex - - YandexBot + - name: SemrushBot + uri: / + - name: SemrushBot-SA + uri: / + - name: Yandex + uri: / + - name: YandexBot + uri: / +# - name: ClaudeBot +# uri: / +# - name: Claude-Web +# uri: / +# - name: Bytedance +# uri: / +# - name: Bytespider +# uri: / +# - name: FacebookBot +# uri: / +# - name: ChatGPT-User +# uri: / +# - name: openai +# uri: / +# - name: openai.com +# uri: / +# - name: GPTBot +# uri: / +# - name: DotBot +# uri: / +# - name: PetalBot +# uri: / nginx_robots_disallowed_uris: false nginx_robots_disallowed_uris_list: [] diff --git a/templates/nginx-virthost.j2 b/templates/nginx-virthost.j2 index 57211f2..3df4d61 100644 --- a/templates/nginx-virthost.j2 +++ b/templates/nginx-virthost.j2 @@ -101,6 +101,9 @@ server { access_log off; } location = /robots.txt { +{% if nginx_install_robots_txt %} + root {{ nginx_webroot }}; +{% endif %} allow all; log_not_found off; access_log off; @@ -248,6 +251,9 @@ server { access_log off; } location = /robots.txt { +{% if nginx_install_robots_txt %} + root {{ nginx_webroot }}; +{% endif %} allow all; log_not_found off; access_log off; diff --git a/templates/robots.txt.j2 b/templates/robots.txt.j2 index 409648f..8e049e7 100644 --- a/templates/robots.txt.j2 +++ b/templates/robots.txt.j2 @@ -3,10 +3,11 @@ User-Agent: * Disallow: / {% else %} {% for ua in nginx_robots_disallowed_useragent_list %} -User-agent: {{ ua }} -Disallow: / +User-agent: {{ ua.name }} +Disallow: {{ ua.uri | default('/') }} {% endfor %} + {% if nginx_robots_disallowed_uris %} User-agent: * {% for uri in nginx_robots_disallowed_uris_list %} @@ -18,4 +19,5 @@ Disallow: {{ uri }} User-Agent: * Crawl-Delay: {{ nginx_robots_crawl_delay }} {% endif %} -{% endif %} \ No newline at end of file +{% endif %} +