Compare commits

...

5 Commits

4 changed files with 47 additions and 13 deletions

View File

@ -149,10 +149,36 @@ nginx_robots_disallow_everything: false
nginx_robots_enable_crawl_delay: false nginx_robots_enable_crawl_delay: false
nginx_robots_crawl_delay: 10 nginx_robots_crawl_delay: 10
nginx_robots_disallowed_useragent_list: nginx_robots_disallowed_useragent_list:
- SemrushBot - name: SemrushBot
- SemrushBot-SA uri: /
- Yandex - name: SemrushBot-SA
- YandexBot 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: false
nginx_robots_disallowed_uris_list: [] nginx_robots_disallowed_uris_list: []

View File

@ -1,10 +1,10 @@
{% if nginx_cors_extended_rules %} {% if nginx_cors_extended_rules %}
if ($request_method = 'OPTIONS') { if ($request_method = 'OPTIONS') {
{% if nginx_cors_limit_origin %} {% if nginx_cors_limit_origin %}
proxy_hide_header Access-Control-Allow-Origin; # proxy_hide_header Access-Control-Allow-Origin;
add_header 'Access-Control-Allow-Origin' '{{ nginx_cors_acl_origin | default("$http_origin") }}'; add_header 'Access-Control-Allow-Origin' '{{ nginx_cors_acl_origin | default("$http_origin") }}';
{% else %} {% else %}
proxy_hide_header Access-Control-Allow-Origin; # proxy_hide_header Access-Control-Allow-Origin;
add_header 'Access-Control-Allow-Origin' '{{ nginx_access_control_allow_origin_src | default("*") }}'; add_header 'Access-Control-Allow-Origin' '{{ nginx_access_control_allow_origin_src | default("*") }}';
{% endif %} {% endif %}
add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Credentials' 'true';
@ -23,10 +23,10 @@ if ($request_method = 'OPTIONS') {
} }
if ($request_method = 'POST') { if ($request_method = 'POST') {
{% if nginx_cors_limit_origin %} {% if nginx_cors_limit_origin %}
proxy_hide_header Access-Control-Allow-Origin; # proxy_hide_header Access-Control-Allow-Origin;
add_header 'Access-Control-Allow-Origin' '{{ nginx_cors_acl_origin | default("$http_origin") }}'; add_header 'Access-Control-Allow-Origin' '{{ nginx_cors_acl_origin | default("$http_origin") }}';
{% else %} {% else %}
proxy_hide_header Access-Control-Allow-Origin; # proxy_hide_header Access-Control-Allow-Origin;
add_header 'Access-Control-Allow-Origin' '{{ nginx_access_control_allow_origin_src | default("*") }}'; add_header 'Access-Control-Allow-Origin' '{{ nginx_access_control_allow_origin_src | default("*") }}';
{% endif %} {% endif %}
add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Credentials' 'true';
@ -36,10 +36,10 @@ if ($request_method = 'POST') {
} }
if ($request_method = 'GET') { if ($request_method = 'GET') {
{% if nginx_cors_limit_origin %} {% if nginx_cors_limit_origin %}
proxy_hide_header Access-Control-Allow-Origin; # proxy_hide_header Access-Control-Allow-Origin;
add_header 'Access-Control-Allow-Origin' '{{ nginx_cors_acl_origin | default("$http_origin") }}'; add_header 'Access-Control-Allow-Origin' '{{ nginx_cors_acl_origin | default("$http_origin") }}';
{% else %} {% else %}
proxy_hide_header Access-Control-Allow-Origin; # proxy_hide_header Access-Control-Allow-Origin;
add_header 'Access-Control-Allow-Origin' '{{ nginx_access_control_allow_origin_src | default("*") }}'; add_header 'Access-Control-Allow-Origin' '{{ nginx_access_control_allow_origin_src | default("*") }}';
{% endif %} {% endif %}
add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Credentials' 'true';

View File

@ -101,6 +101,9 @@ server {
access_log off; access_log off;
} }
location = /robots.txt { location = /robots.txt {
{% if nginx_install_robots_txt %}
root {{ nginx_webroot }};
{% endif %}
allow all; allow all;
log_not_found off; log_not_found off;
access_log off; access_log off;
@ -248,6 +251,9 @@ server {
access_log off; access_log off;
} }
location = /robots.txt { location = /robots.txt {
{% if nginx_install_robots_txt %}
root {{ nginx_webroot }};
{% endif %}
allow all; allow all;
log_not_found off; log_not_found off;
access_log off; access_log off;

View File

@ -3,10 +3,11 @@ User-Agent: *
Disallow: / Disallow: /
{% else %} {% else %}
{% for ua in nginx_robots_disallowed_useragent_list %} {% for ua in nginx_robots_disallowed_useragent_list %}
User-agent: {{ ua }} User-agent: {{ ua.name }}
Disallow: / Disallow: {{ ua.uri | default('/') }}
{% endfor %} {% endfor %}
{% if nginx_robots_disallowed_uris %} {% if nginx_robots_disallowed_uris %}
User-agent: * User-agent: *
{% for uri in nginx_robots_disallowed_uris_list %} {% for uri in nginx_robots_disallowed_uris_list %}
@ -18,4 +19,5 @@ Disallow: {{ uri }}
User-Agent: * User-Agent: *
Crawl-Delay: {{ nginx_robots_crawl_delay }} Crawl-Delay: {{ nginx_robots_crawl_delay }}
{% endif %} {% endif %}
{% endif %} {% endif %}