Skip to content

VirtualServer > Action.Return.type overwritten when URI contains an extension #6943

@yaronuliel

Description

@yaronuliel

Version

edge

What Kubernetes platforms are you running on?

Minikube

Description:

When defining a VirtualServer resource - you can set a preconfigured response - one of the fields it supports is type which according to the docs sets "The MIME type of the response"

In fact - it only sets the default_type (nginx docs) (location in source code) - the implications are that despite setting the desired Content-Type value - when the URI ends with an extension - nginx "guesses" the Content-Type based on the map in /etc/nginx/mime.types

Expected Behavior

When defining a type in a route with return action - it should always return that type as Content-Type, and should ignore not use the extension in the URI to assume the content type

Steps To Reproduce:

  1. Apply this following VirtualServer yaml (set host according to your installation):
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
  name: virtual-server-bug-demo
spec:
  host: vs-bug-demo.localhost
  routes:
  - path: /
    action:
        return:
          body: "Not Found"
          code: 404
          type: text/plain
  1. Browse to http://vs-bug-demo.localhost/not-found - All good, response is 404 with content typetext/plain
  2. Browse to http://vs-bug-demo.localhost/not-found/somelinkwith.mp4 - Server response with Content-type: video/mp4 (body still contains the string "Not Found" - which cause the browser to show an invalid video player)

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalAn issue that proposes a feature requestready for refinementAn issue that was triaged and it is ready to be refined

    Type

    No type

    Projects

    Status

    Prioritized backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions