nginx入口Jenkins路径重写配置不起作用

前端之家收集整理的这篇文章主要介绍了nginx入口Jenkins路径重写配置不起作用 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我已经在Kubernetes上部署了Jenkins,并且正在尝试为其配置Nginx入口.

假设我希望它在https://myip/jenkins可用

这是我的初始入口配置:

apiVersion: extensions/v1beta1
kind: Ingress
Metadata:
  name: jenkins-ingress
  annotations:
    kubernetes.io/ingress.class: Nginx
    Nginx.ingress.kubernetes.io/ssl-redirect: "true"
    Nginx.ingress.kubernetes.io/rewrite-target: /
    Nginx.ingress.kubernetes.io/add-base-url: "true"
spec:
  rules:
  - http:
      paths:
      - path: /jenkins
        backend:
          serviceName: jenkins
          servicePort: 8080

这样,当我访问https:// myip / jenkins时,我将重定向到http:// myip / login?from = /.

当访问https:// myip / jenkins / login?from = /时,它停留在该页面上,但是未找到任何静态资源,因为它们的查找位置为https://myip/static

最佳答案
这是我解决了配置Jenkins图片上下文路径而无需使用入口重写注释的方式:

kind: Deployment
Metadata:
  creationTimestamp: null
  labels:
    app: jenkins
  name: jenkins
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jenkins
  strategy: {}
  template:
    Metadata:
      creationTimestamp: null
      labels:
        app: jenkins
    spec:
      securityContext:
        fsGroup: 2000
        runAsUser: 1000
        runAsNonRoot: true
      volumes:
      - name: jenkins-storage
        persistentVolumeClaim:
          claimName: jenkins
      containers:
      - image: jenkins/jenkins:lts
        name: jenkins
        ports:
        - containerPort: 8080
          name: "http-server"
        - containerPort: 50000
          name: "jnlp"
        resources: {}
        env:
        - name: JENKINS_OPTS
          value: --prefix=/jenkins
        volumeMounts:
        - mountPath: "/var/jenkins_home"
          name: jenkins-storage
status: {}

入口:

apiVersion: extensions/v1beta1
kind: Ingress
Metadata:
  name: prfl-apps-devops-ingress
  annotations:
    kubernetes.io/ingress.class: Nginx
    Nginx.ingress.kubernetes.io/ssl-redirect: "false"
    Nginx.ingress.kubernetes.io/add-base-url: "true"
spec:
  rules:
  - http:
      paths:
      - path: /jenkins
        backend:
          serviceName: jenkins
          servicePort: 8080
原文链接:https://www.f2er.com/nginx/532363.html

猜你在找的Nginx相关文章