nginx - kubernetes nginx到子域重定向的入口子路径

标签 nginx kubernetes nginx-ingress guacamole

我正在尝试实现以下proxy_pass设置,基本上其中一项服务是列出到subdomain.example.com/guacamole,但我想将其用作subdomain.example.com

    location / {
    proxy_pass http://guacamole:8080/guacamole/;
    proxy_buffering off;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_cookie_path /guacamole/ /;
    access_log off;
    # allow large uploads (default=1m)
    # 4096m = 4GByte
    client_max_body_size 4096m;
    }
以下是nginx入口
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: guacamole-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  tls:
  - hosts:
    - subdomain.example.com
  rules:
  - host: subdomain.example.com
    http:
      paths:
      - path: /guacamole
        backend:
          serviceName: service-guacamole-frontend
          servicePort: 8080
我尝试使用nginx.ingress.kubernetes.io/rewrite-target: /,但没有用。

最佳答案

path: /guacamole替换path: /应该可以解决问题。

  rules:
  - host: subdomain.example.com
    http:
      paths:
      - path: /  # replace `/guacamole` with `/`
        backend:
          serviceName: service-guacamole-frontend
          servicePort: 8080

关于nginx - kubernetes nginx到子域重定向的入口子路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63851129/

相关文章:

ssl - 设置配置了 SSL 的 Nginx 服务器

NGINX 代理传递请求 URL 的一部分

nginx - nginx 上游代理的后备

docker - 用于链接容器的 Kubernetes 配置

ssl - nginx ssl3_get_record 版本号错误 502 Bad Gateway

kubernetes - 入口路由api前缀问题

mysql - 您的 PHP 安装似乎缺少 WordPress 所需的 MySQL 扩展。在 Ubuntu 14.04 LTS 上

kubernetes - 如何为 Kubernetes 中的特定部署禁用 istio-proxy sidecar 访问日志

kubernetes - kubernetes.default.svc是怎么路由到api服务器的?

kubernetes-ingress - 如何在 Helm 安装的 ingress-nginx 中使用通配符证书?