Serve a robots.txt that keeps crawlers off expensive pages #5
@@ -37,6 +37,11 @@ gitea_postgresql_resources:
|
||||
memory: 2Gi
|
||||
ephemeral-storage: 2Gi
|
||||
|
||||
# robots.txt served at https://<host>/robots.txt. The default asks crawlers to
|
||||
# skip the expensive per-commit pages (blame, history, raw, archives). Point
|
||||
# this at your own file to change it.
|
||||
gitea_robots_txt: "{{ role_path }}/files/robots.txt"
|
||||
|
||||
# Gitea's Helm chart (gitea/gitea). Pinned so a rerun of the role never
|
||||
# upgrades Gitea by surprise. 12.7.0 ships Gitea 1.27.0 and is the version
|
||||
# deployed on 2026-11-09. Bump it deliberately, after reading the chart's
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
# gitea.eom.dev: crawlers are welcome on repository front pages, issues and releases,
|
||||
# but please skip the expensive per-commit views (they overloaded a small server).
|
||||
User-agent: *
|
||||
Crawl-delay: 10
|
||||
Disallow: /*/*/blame/
|
||||
Disallow: /*/*/commit/
|
||||
Disallow: /*/*/commits/
|
||||
Disallow: /*/*/raw/
|
||||
Disallow: /*/*/media/
|
||||
Disallow: /*/*/src/commit/
|
||||
Disallow: /*/*/src/tag/
|
||||
Disallow: /*/*/compare/
|
||||
Disallow: /*/*/archive/
|
||||
Disallow: /*/*/_edit/
|
||||
Disallow: /*/*/_delete/
|
||||
Disallow: /*/*/_new/
|
||||
Disallow: /*/*/rss/
|
||||
Disallow: /*/*/atom/
|
||||
Disallow: /*/*/graph
|
||||
Disallow: /*/*/activity
|
||||
Disallow: /*/*/search
|
||||
Disallow: /*/*/find/
|
||||
Disallow: /*/*/wiki/?action=_revision
|
||||
Disallow: /api/
|
||||
Disallow: /explore/code
|
||||
Disallow: /user/
|
||||
Disallow: /DevOps/truecharts/
|
||||
@@ -13,6 +13,22 @@
|
||||
when: repo_update.changed
|
||||
tags: [actions]
|
||||
|
||||
# Gitea serves $GITEA_CUSTOM/public/robots.txt at /robots.txt. Without one,
|
||||
# crawlers walked blame and commit pages and overloaded the 1-CPU node Gitea
|
||||
# shares with other apps (2026-11-18: the Discourse database there kept restarting).
|
||||
- name: robots.txt for crawlers
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
definition:
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: gitea-robots
|
||||
namespace: gitea
|
||||
data:
|
||||
robots.txt: "{{ lookup('file', gitea_robots_txt) }}"
|
||||
register: gitea_robots
|
||||
|
||||
- name: deploy gitea
|
||||
kubernetes.core.helm:
|
||||
name: gitea
|
||||
@@ -63,6 +79,17 @@
|
||||
secretName: gitea-tls
|
||||
persistence:
|
||||
size: 2Ti
|
||||
# A subPath mount does not follow ConfigMap edits; a later task restarts
|
||||
# Gitea when robots.txt changes.
|
||||
extraVolumes:
|
||||
- name: robots
|
||||
configMap:
|
||||
name: gitea-robots
|
||||
extraContainerVolumeMounts:
|
||||
- name: robots
|
||||
mountPath: /data/gitea/public/robots.txt
|
||||
subPath: robots.txt
|
||||
readOnly: true
|
||||
gitea:
|
||||
metrics:
|
||||
enabled: true
|
||||
@@ -176,6 +203,10 @@
|
||||
postgresql-ha:
|
||||
enabled: false
|
||||
|
||||
- name: Restart Gitea to pick up a changed robots.txt
|
||||
command: kubectl -n gitea rollout restart deployment/gitea
|
||||
when: gitea_robots.changed
|
||||
|
||||
- name: Send Gitea's sign-up button to the eom.dev membership site
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
|
||||
Reference in New Issue
Block a user