K8s Nginx Ingress 控制器 RewriteRule

huangapple go评论60阅读模式
英文:

K8s Nginx Ingress controller RewriteRule

问题

需要将Apache配置迁移到K8s Nginx Ingress控制器,我卡在了这一部分:

<Directory /var/www/html/motos>
  RewriteRule ^/?.+Portal/index.php(.*)$ /motos/auto_portal/index.php$1
  RewriteRule ^/?.+Portal/private/?(.*)$ /motos/auto_portal/private/$1
  RewriteRule ^/?.+Portal/scripts/?(.*)$ /motos/auto_portal/scripts/$1
  RewriteRule ^/?.+Portal/graphics/?(.*)$ /motos/auto_portal/graphics/$1
</Directory>

看起来我可以在注释中定义它,但我找不到如何实现的良好示例。

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: motos-site
  annotations:
    [这里似乎应该定义规则?]
spec:
  rules:
  - host: [some-host.com]
    http:
      paths:
      - path: [?]
      ...
英文:

I need to move Apache config to K8s Nginx ingress controller and I stucked on this part:

&lt;Directory /var/www/html/motos&gt;
  RewriteRule ^/?.+Portal/index.php(.*)$ /motos/auto_portal/index.php$1
  RewriteRule ^/?.+Portal/private/?(.*)$ /motos/auto_portal/private/$1
  RewriteRule ^/?.+Portal/scripts/?(.*)$ /motos/auto_portal/scripts/$1
  RewriteRule ^/?.+Portal/graphics/?(.*)$ /motos/auto_portal/graphics/$1
&lt;/Directory&gt;

Looks like I can define it in annotation, but I can`t find good example how I can do it.

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: motos-site
  annotations:
    [looks like here should be defined rules?]
spec:
  rules:
  - host: [some-host.com]
    http:
      paths:
      - path: [?]
      ...

答案1

得分: 0

需要休息一下,这些规则与目录有关,与交通规则无关,需要重写 :/
K8s Nginx Ingress 不参与此过程。

英文:

Need some rest, these rules related to dir and not related to traffic rules rewrite :/
K8s Nginx ingress does not involved in this process.

huangapple
  • 本文由 发表于 2023年4月7日 03:18:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/75953033.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定