K8s Nginx Ingress 控制器 RewriteRule

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

K8s Nginx Ingress controller RewriteRule

问题

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

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

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

  1. ---
  2. apiVersion: networking.k8s.io/v1
  3. kind: Ingress
  4. metadata:
  5. name: motos-site
  6. annotations:
  7. [这里似乎应该定义规则?]
  8. spec:
  9. rules:
  10. - host: [some-host.com]
  11. http:
  12. paths:
  13. - path: [?]
  14. ...
英文:

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

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

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

  1. ---
  2. apiVersion: networking.k8s.io/v1
  3. kind: Ingress
  4. metadata:
  5. name: motos-site
  6. annotations:
  7. [looks like here should be defined rules?]
  8. spec:
  9. rules:
  10. - host: [some-host.com]
  11. http:
  12. paths:
  13. - path: [?]
  14. ...

答案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:

确定