当我尝试在入口服务中使用不同于/和重写注释的路径时,我得到了一个"错误超时";在浏览器。我需要能够访问我的前面像example.com/dev和前端的pod需要接收请求/。我使用Azure K8s 1.22.6和Nginx ingress 4.1.0。这是我的资源:
apiVersion: v1
kind: Service
metadata:
name: frontend-service
spec:
selector:
app: frontend
type: LoadBalancer
ports:
- protocol: TCP
port: 80
targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend-deployment
spec:
replicas: 1
selector:
matchLabels:
app: frontend
template:
metadata:
labels:
app: frontend
spec:
containers:
- name: frontend
image: ealen/echo-server
ports:
- containerPort: 80
imagePullPolicy: Always
和入口。这个配置可以工作,我留下了需要注释的行:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-fa
# annotations:
# nginx.ingress.kubernetes.io/use-regex: "true"
#nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
ingressClassName: nginx
rules:
- http:
paths:
#- path: /dev(/|$)(.*)
- path: /
pathType: Prefix
backend:
service:
name: frontend-service
port:
number: 80
如果我使用重写注释$2和路径"/dev(/|$)(.*)"然后我得到"err_connection_time_out"。我错过了什么?
问题是在前端价值应用程序-我添加了
publicPath: '/dev/',
放到vue.config.js
ps我已经跳过了echo服务