入口重写字符串被忽略
Ingress rewrite string is being ignored
要求是访问https://meals.food.com/burger2中的汉堡服务。
应用程序中的上下文路径是 /burger
.
入口
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /burger/
spec:
rules:
- host: meals.food.com
http:
paths:
- backend:
service:
name: burger
port:
number: 80
path: /burger2(/|$)(.*)
pathType: Prefix
检查入口控制器日志后:
[05/Jan/2022:13:54:11 +0000] "GET // HTTP/1.1" 304 0 "-" "Mozilla/5.0
(X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/96.0.4664.110 Safari/537.36" 957 0.002 [anotherservice-80] []
x.x.x.x:80 0 0.002 304 230200x023
我的入口配置是否正确?
我怀疑有什么东西改变了我从浏览器到入口控制器的请求。
Is my ingress config correct? My suspicion is that something is altering the request between my request from the browser to ingress-controller.
您的 ingress config 看起来不错。我没有看到任何错误。他将采取以下行动:
示例地址 meals.food.com/burger2/blah-blah-blah
将重写为 meals.food.com/burger/blah-blah-blah
。如果那是您的意图,那么配置就可以了。
但是你有 304
HTTP code.
The HTTP 304 Not Modified
client redirection response code indicates that there is no need to retransmit the requested resources. It is an implicit redirection to a cached resource. This happens when the request method is safe, like a GET
or a HEAD
request, or when the request is conditional and uses a If-None-Match
or a If-Modified-Since
header.
The equivalent 200
OK
response would have included the headers Cache-Control
, Content-Location
, Date
, ETag
, Expires
, and Vary
.
也就是说
当浏览器收到请求,但不知道它是否具有最新版本的写入时,它会发送条件验证请求,通过 If-Modified-Since
或 [=16= 将最后修改日期和时间传达给服务器] header.
服务器然后检查这些 header 并确定它们的值是否相同。如果是这样 - 服务器将发回 HTTP 304 代码,浏览器将使用资源的缓存副本。如果没有,则说明文件已被修改,因此浏览器将通过发送 HTTP 200 代码保存一份新副本。
在你的情况下,看起来好像有人试图多次下载相同的(未更改的)资源,因此得到代码 304。如果是这样,一切都很好。
要求是访问https://meals.food.com/burger2中的汉堡服务。
应用程序中的上下文路径是 /burger
.
入口
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /burger/
spec:
rules:
- host: meals.food.com
http:
paths:
- backend:
service:
name: burger
port:
number: 80
path: /burger2(/|$)(.*)
pathType: Prefix
检查入口控制器日志后:
[05/Jan/2022:13:54:11 +0000] "GET // HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36" 957 0.002 [anotherservice-80] [] x.x.x.x:80 0 0.002 304 230200x023
我的入口配置是否正确? 我怀疑有什么东西改变了我从浏览器到入口控制器的请求。
Is my ingress config correct? My suspicion is that something is altering the request between my request from the browser to ingress-controller.
您的 ingress config 看起来不错。我没有看到任何错误。他将采取以下行动:
示例地址 meals.food.com/burger2/blah-blah-blah
将重写为 meals.food.com/burger/blah-blah-blah
。如果那是您的意图,那么配置就可以了。
但是你有 304
HTTP code.
The HTTP
304 Not Modified
client redirection response code indicates that there is no need to retransmit the requested resources. It is an implicit redirection to a cached resource. This happens when the request method is safe, like aGET
or aHEAD
request, or when the request is conditional and uses aIf-None-Match
or aIf-Modified-Since
header.The equivalent
200
OK
response would have included the headersCache-Control
,Content-Location
,Date
,ETag
,Expires
, andVary
.
也就是说
当浏览器收到请求,但不知道它是否具有最新版本的写入时,它会发送条件验证请求,通过 If-Modified-Since
或 [=16= 将最后修改日期和时间传达给服务器] header.
服务器然后检查这些 header 并确定它们的值是否相同。如果是这样 - 服务器将发回 HTTP 304 代码,浏览器将使用资源的缓存副本。如果没有,则说明文件已被修改,因此浏览器将通过发送 HTTP 200 代码保存一份新副本。
在你的情况下,看起来好像有人试图多次下载相同的(未更改的)资源,因此得到代码 304。如果是这样,一切都很好。