-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: VirtualServer > Action.Return.type overwritten when URI contains an extension #6943
Comments
Hi @yaronuliel thanks for reporting! Be sure to check out the docs and the Contributing Guidelines while you wait for a human to take a look at this 🙂 Cheers! |
@yaronuliel could you please share generated NGINX config? This will help us investigate the issue. |
@jjngx 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 The created resource yaml is: apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"k8s.nginx.org/v1","kind":"VirtualServer","metadata":{"annotations":{},"name":"virtual-server-bug-demo","namespace":"vs-demo"},"spec":{"host":"vs-bug-demo.localhost","routes":[{"action":{"return":{"body":"Not Found","code":404,"type":"text/plain"}},"path":"/"}]}}
creationTimestamp: "2024-12-24T18:48:42Z"
generation: 1
name: virtual-server-bug-demo
namespace: vs-demo
resourceVersion: "424986"
uid: ec36b225-364a-4761-a755-6fde9c4ec690
spec:
host: vs-bug-demo.localhost
routes:
- action:
return:
body: Not Found
code: 404
type: text/plain
path: /
status:
externalEndpoints:
- hostname: localhost
ports: '[80,443]'
message: 'Configuration for vs-demo/virtual-server-bug-demo was added or updated '
reason: AddedOrUpdated
state: Valid The config generated in the nginx controller in
The problem caused by using |
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 istype
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 desiredContent-Type
value - when the URI ends with an extension - nginx "guesses" theContent-Type
based on the map in/etc/nginx/mime.types
Expected Behavior
When defining a
type
in a route withreturn
action - it should always return that type asContent-Type
, and should ignore not use the extension in the URI to assume the content typeSteps To Reproduce:
VirtualServer
yaml (sethost
according to your installation):text/plain
Content-type: video/mp4
(body still contains the string "Not Found" - which cause the browser to show an invalid video player)The text was updated successfully, but these errors were encountered: