I'm trying to get my website up and running on kubernetes. I'm using ingress to route the site.
nginx-conf:
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
Kubernetes deployment:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: mywebsite
spec:
replicas: 2
template:
metadata:
labels:
app: mywebsite
spec:
containers:
- name: mywebsite
image: containerurl/xxx/mywebsite:latest
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: mywebsite
spec:
ports:
- port: 82
targetPort: 80
selector:
app: mywebsite
Ingress config:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: myIngress
annotations:
kubernetes.io/tls-acme: "true"
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
tls:
- hosts:
- xxx.com
secretName: tls-secret
rules:
- host: xxx.com
http:
paths:
- path: /mywebsite
backend:
serviceName: mywebsite
servicePort: 82
When i go to xxx.com/mywebiste, the index.html is loading, but the css and js are not loaded (404):
index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My Website</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link href="/styles.30457fcf45ea2da7cf6a.css" rel="stylesheet"></head>
<body>
<div id="react-root"></div>
<script type="text/javascript" src="/app.171d6a95cf24d8abab14.js"></script></body>
</html>
Any idea on how can this work?