How to serve a static content using ingress nginx

5/12/2020

I have one service called "workspace-service-b6" which is running on port 5000, See the below ingress file. Now I want to serve the static content on the same service (workspace-service-b6) by adding the path route.

Example:- Service is working on https://workspace-b6.dev.example.com

Now if the user adds "/workspace/v2/ "at the end of the URL.

Like this:- https://workspace-b6.dev.example.com/workspace/v2/ it will redirect to s3 bucket "https://s3.console/buckets/xyz/abc/build" where my static content is available.

My Ingress file :-

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: b6-ingress 
namespace: b6
annotations:
kubernetes.io/ingress.class: "nginx"
kubernetes.io/tls-acme: "true"
spec:
tls:
- hosts:
- workspace-b6.dev.example.com
secretName: xyz-crt
rules:
- host: workspace-b6.dev.example.com
http:
paths:
- backend:
serviceName: workspace-service-b6
service port: 5000
-- me25
kubernetes
kubernetes-ingress
nginx
nginx-ingress

1 Answer

5/12/2020

While it’s kind of possible, the real answer is “don’t”. The ingress system is just a proxy, set up separate pods for content.

-- coderanger
Source: StackOverflow