nginx - 位置块上的 nginx add_headers 被删除
问题描述
我用谷歌搜索但没有找到解决我的问题的方法:
add_header X-debug-message "debug-msg 1" always;
location ^~ /backend {
try_files $uri $uri/ /back.php?$args;
add_header X-debug-message "debug-msg 2" always;
}
add_header X-debug-message "debug-msg 3" always;
所以,对于/backend
位置,我只能看到"debug-msg 1"
和"debug-msg 3"
标题。为什么我看不到"debug-msg 2"
?我确定/backend
输入了位置块。
解决方案
是的。它的行为记录在案:
可能有几个 add_header 指令。当且仅当当前级别上没有定义 add_header 指令时,这些指令才从上一层继承
你应该看看 more_set_headers 作为替代品
推荐阅读
- javascript - 尽管 redux 状态已更新,但组件不会重新渲染
- ios - 如何在 Swift 中不四舍五入地打印只有 2 位数字的浮点数?
- javascript - 使用 Dragula 时拖动元素时出现问题
- html - 调整图像大小后填充剩余空间,保持其纵横比
- android - Android Firebase:onDisconnect 不起作用
- c# - .net - 消费者驱动的 SOAP/XML 合同?
- oracle - 如何从 Oracle SQL 中的表中取消透视
- php - PHP imap_search KEYWORD 文档如何使用
- python - 理解列表与 for 循环的复杂性
- angular - 操作后如何在 ionic 4 中刷新 observable