Opened 10 years ago

Closed 10 years ago

#595 closed defect (invalid)

add_header replaces previous headers when included

Reported by: Goz3rr Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.7.x
Keywords: Cc:
uname -a: Linux newton 2.6.32-042stab090.5 #1 SMP Sat Jun 21 00:15:09 MSK 2014 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.7.3
built by gcc 4.7.2 (Debian 4.7.2-5)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --user=www-data --group=www-data --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --with-ipv6 --without-http_uwsgi_module --without-http_scgi_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_ssl_module --with-http_spdy_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --add-module=modules/nginx-rtmp-module

Description

My nginx config is basically the following:

http {
  #whole bunch of other options left out
  add_header "test1" "value1";
  include sites-enabled/*.conf;
}

Where a file in sites-enabled looks like this:

server {
  listen 80;
  server_name example.com;
  #root, access_log etc left out
  add_header "test2" "value2";
}

Only the test2 header shows up, while i expect both headers to show up in the output.

Change History (1)

comment:1 by Maxim Dounin, 10 years ago

Resolution: invalid
Status: newclosed

This is expected behaviour. Quote from docs:

These directives are inherited from the previous level if and only if there are no add_header directives defined on the current level.

Note: See TracTickets for help on using tickets.