azure - Nginx 路由忽略路径规则之后的任何内容

标签 azure nginx kubernetes kubernetes-ingress nginx-ingress

我们正在为 formio 设置 nginx 和 kubernetes。我们需要 .com/指向 api 服务器,.com/files/指向 pdf 服务器。这是入口配置:

  paths:
  - backend:
      serviceName: formio
      servicePort: 80
    path: /
  - backend:
      serviceName: formio-files
      servicePort: 4005
    path: /files/(.*)$

我们设置了 PDF 存储在/files/pdf/filename 等路径中。 问题是/files/之后的整个路径也被重定向到 PDF 服务器,而不是仅仅停在/files/

最佳答案

这是一个常见问题,是由您设置的路径正则表达式引起的。首先,你需要清楚地了解它。路径正则表达式 /files/(.*)$ 将匹配所有路径 /files/...,无论您在 /files/< 之后添加什么。因此它会使用路径 /files/... 重定向所有请求。如果您只想将 PDF 请求重定向到路径 /files/pdf/...,解决方案是将路径正则表达式设置为 /files/pdf/(.*)$.

关于azure - Nginx 路由忽略路径规则之后的任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58839056/

相关文章:

nginx - 如何重写路径、转发参数和添加参数?

kubernetes - 如果我可以解码 Kubernetes secret ,它们有什么意义?

kubernetes - 预安装 Hook Helm - 用户友好的错误消息

azure - 在 Azure 容器实例上执行命令时,_callback 中出现错误 "...websocket/_app.py",第 345 行

reactjs - 使用 Azure DevOps 将 React 应用程序部署到 Azure Web App 时发布失败

python - 在 nginx 上运行 django 时提供测试页面

apache - ssl + nginx + apache + php : links are still displayed as http, 不是 https

docker - 是否可以在 Google Kubernetes Engine 上拥有临时的磁盘 pod 存储?

azure - 如何监控 Azure VM 上的 Windows 服务?

azure - 查找与 Azure Synapse 数据仓库中的存储过程相关的所有表