深度阅读

How to add headers to an nginx response?

作者
作者
2023年08月22日
更新时间
7.15 分钟
阅读时间
0
阅读量

To add headers to an nginx response, you can use the add_header directive in your nginx configuration file. Here is an example:

location /endpoint {
    # other directives
    add_header X-Custom-Header "Custom Header Value";
}

In this example, X-Custom-Header is the name of the header, and Custom Header Value is the value of the header. You can add as many headers as you need by including multiple add_header directives within the applicable location block in your nginx configuration.

Note that while add_header adds the header to the response, you can also modify the values of existing headers using the add_header directive with the same header name as what you want to modify.

相关标签

博客作者

热爱技术,乐于分享,持续学习。专注于Web开发、系统架构设计和人工智能领域。