Skip to content

Instantly share code, notes, and snippets.

@AlexGluck
Last active April 19, 2025 06:26
Show Gist options
  • Save AlexGluck/aca78a90520a929b1b1efc933540e60c to your computer and use it in GitHub Desktop.
Save AlexGluck/aca78a90520a929b1b1efc933540e60c to your computer and use it in GitHub Desktop.
ingress-nginx manifests for sonatype nexus docker repositories
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nexus-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.org/client-max-body-size: "0"
nginx.org/proxy-buffering: "off"
nginx.org/http-snippets: |
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=nexus:100m inactive=30d max_size=2g;
nginx.org/server-snippets: |
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header X-Forwarded-Proto $scheme;
spec:
ingressClassName: nginx
rules:
- host: nexus.example.org
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nexus
port:
name: nexus
...
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nexus-ingress-api
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: true
nginx.ingress.kubernetes.io/rewrite-target: "/$1$is_args$args"
spec:
ingressClassName: nginx
rules:
- host: nexus.example.org
http:
paths:
- path: "/api/(.*)"
pathType: Prefix
backend:
service:
name: nexus
port:
name: nexus
...
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nexus-ingress-docker-push
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: true
nginx.ingress.kubernetes.io/rewrite-target: "/repository/$2/$1/$2/$2/$3/blobs/uploads/$is_args$args"
spec:
ingressClassName: nginx
rules:
- host: nexus.example.org
http:
paths:
- path: '/(v1|v2)/([-_0-9a-z\.]+)/(.*)/blobs/uploads/$'
pathType: Prefix
backend:
service:
name: nexus
port:
name: nexus
...
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nexus-ingress-docker-login
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: true
nginx.ingress.kubernetes.io/rewrite-target: "/repository/docker-login/$1/$2$is_args$args"
spec:
ingressClassName: nginx
rules:
- host: nexus.example.org
http:
paths:
- path: "/(v1|v2)/$"
pathType: Prefix
backend:
service:
name: nexus
port:
name: nexus
...
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nexus-ingress-docker-search
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: true
nginx.ingress.kubernetes.io/rewrite-target: "/repository/docker-group/$1/$2$is_args$args"
spec:
ingressClassName: nginx
rules:
- host: nexus.example.org
http:
paths:
- path: "/(v1|v2)/(_catalog|search)$"
pathType: Prefix
backend:
service:
name: nexus
port:
name: nexus
...
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nexus-ingress-docker-registry-fallback-latest
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: "/repository/docker-group/$1/$2$is_args$args"
spec:
ingressClassName: nginx
rules:
- host: nexus.example.org
http:
paths:
- path: "@fallback2"
pathType: Prefix
backend:
service:
name: nexus
port:
name: nexus
...
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nexus-ingress-docker-pull-norepo
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: true
nginx.ingress.kubernetes.io/rewrite-target: "/repository/library/$1/library/library/$2/$3$is_args$args"
nginx.ingress.kubernetes.io/configuration-snippet: |
error_page 404 500 = @fallback2;
proxy_intercept_errors on;
recursive_error_pages on;
proxy_cache nexus;
proxy_cache_valid 500 10d;
proxy_cache_min_uses 3;
proxy_cache_valid 404 15m;
proxy_cache_use_stale http_500;
spec:
ingressClassName: nginx
rules:
- host: nexus.example.org
http:
paths:
- path: "/(v1|v2)/([-_0-9a-z\\.]+)/(blobs/sha256.*|manifests/.*)$"
pathType: Prefix
backend:
service:
name: nexus
port:
name: nexus
...
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nexus-ingress-docker
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: true
nginx.ingress.kubernetes.io/rewrite-target: "/repository/$2/$1/$2/$3$is_args$args"
nginx.ingress.kubernetes.io/configuration-snippet: |
error_page 404 500 = @fallback;
proxy_intercept_errors on;
recursive_error_pages on;
proxy_cache nexus;
proxy_cache_valid 500 10d;
proxy_cache_min_uses 3;
proxy_cache_valid 404 15m;
proxy_cache_use_stale http_500;
spec:
ingressClassName: nginx
rules:
- host: nexus.example.org
http:
paths:
- path: "/(v1|v2)/([-_0-9a-z\\.]+)/(.*)$"
pathType: Prefix
backend:
service:
name: nexus
port:
name: nexus
...
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nexus-ingress-docker-registry-fallback
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: "/repository/$2/$1/$3$is_args$args"
nginx.ingress.kubernetes.io/configuration-snippet: |
error_page 404 500 = @fallback2;
proxy_intercept_errors on;
recursive_error_pages on;
proxy_cache nexus;
proxy_cache_valid 500 10d;
proxy_cache_min_uses 3;
proxy_cache_valid 404 15m;
proxy_cache_use_stale http_500;
spec:
ingressClassName: nginx
rules:
- host: nexus.example.org
http:
paths:
- path: "@fallback"
pathType: Prefix
backend:
service:
name: nexus
port:
name: nexus
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment