Created
June 29, 2021 15:10
-
-
Save denibertovic/1560c2e9b0f543a344bd31267ae88070 to your computer and use it in GitHub Desktop.
Proxy static files from S3 with Kubernetes and Nginx Ingress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: my-s3-static-svc | |
spec: | |
externalName: <MY_S3_BUCKET_NAME>.s3.<MY_S3_BUCKET_REGION>.amazonaws.com | |
type: ExternalName | |
ports: | |
- name: http | |
port: 80 | |
protocol: TCP | |
targetPort: 80 | |
--- | |
apiVersion: networking.k8s.io/v1 | |
kind: Ingress | |
metadata: | |
annotations: | |
nginx.ingress.kubernetes.io/rewrite-target: /static/$2 | |
nginx.ingress.kubernetes.io/upstream-vhost: <MY_S3_BUCKET_NAME>.s3.<MY_S3_BUCKET_REGION>.amazonaws.com | |
nginx.ingress.kubernetes.io/use-regex: "true" | |
name: my-ingress | |
spec: | |
rules: | |
- host: www.mydomain.com | |
http: | |
paths: | |
- path: /static(/|$)(.*) | |
backend: | |
service: | |
name: my-s3-static-svc | |
port: 80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment