hi,all:
hello, I config "add_header Server xxxx;", then I get response
header:
< HTTP/1.1 200 OK
< Server: nginx/0.8.17
< Date: Mon, 05 Oct 2009 07:59:18 GMT
< Content-Type: text/html
< Content-Length: 151
< Last-Modified: Mon, 05 Oct 2009 07:24:51 GMT
< Connection: keep-alive
< Server: xxxx
< Accept-Ranges: bytes
We can see Server field is printed twice. I need replace first one.
So I read source code, found:
1.add_header is simple push to header_out array, keep
headers_out.server == NULL.
2. “Server:nginx/0.8.17” field is setted at
http_header_filter_module.c:457
3. a loop start at http_header_filter_module.c:568, it concat all
header fields(include “Server xxxx”).
4. Server field is replication.
why not set headers_out.server at add_header? how to implement my need?
sorry for my poor english.
thanks
bb
Hello!
On Mon, Oct 05, 2009 at 04:11:53PM +0800, bit bull wrote:
< Connection: keep-alive
3. a loop start at http_header_filter_module.c:568, it concat all
header fields(include “Server xxxx”).
4. Server field is replication.
why not set headers_out.server at add_header? how to implement my need?
-
Directive add_header does not support arbitrary header rewriting.
-
No, you can’t redefine Server header without patching code. It
isn’t considered to be good thing to do, but for those who still
thinks that hiding head in sand is a good way to handle security
there is directive “server_tokens off;” which will hide version
string from Server header and standard error pages.
Maxim D.
- why not support any header rewriting? I think this feature will
make a flexible config-file.
- I used “server_tokens off;”. thanks
2009/10/5 Maxim D. [email protected]:
thanks for your help~ Headers-More module looks very useful.
2009/10/6 agentzh [email protected]:
On Tue, Oct 6, 2009 at 1:03 AM, bit bull [email protected] wrote:
- why not support any header rewriting? I think this feature will
make a flexible config-file.
- I used “server_tokens off;”. thanks
Well, this could be easily done by a custom C module (implemented as
an output header filter perhaps). I’m pondering writing a Headers-More
module, which will also provide an option to manipulate headers of
pages with 4xx and 5xx status codes.
Cheers,
-agentzh
I think Igor and others will like it.haha~
BTW: What’s the echo-module?
2009/10/7 agentzh [email protected]:
On Tue, Oct 6, 2009 at 8:10 PM, bit bull [email protected] wrote:
thanks for your help~ Headers-More module looks very useful.
I’ll look into it after I finished my nginx-echo-module in the next
few days. I’d also turn it into a patch to the standard headers module
if Igor and others like it.
Stay tuned!
-agentzh
oh~so interesting!
2009/10/8 agentzh [email protected]:
On Wed, Oct 7, 2009 at 1:42 PM, bit bull [email protected] wrote:
I think Igor and others will like it.haha~

BTW: What’s the echo-module?
A simple module that lets nginx to echo things directly just like a
classic CGI script (but without CGI or Perl of course):
GitHub - openresty/echo-nginx-module: An Nginx module for bringing the power of "echo", "sleep", "time" and more to Nginx's config file
Currently only “echo” and “echo_client_request_headers” directives are
supported. I’m working on “echo_sleep” (a non-blocking sleep on the
server side) directively atm. “echo_location” and filter versions of
“echo_before_body” and “echo_after_body” are also on my TODO list.
Cheers,
-agentzh
On Mon, Oct 5, 2009 at 4:11 PM, bit bull [email protected] wrote:
< Connection: keep-alive
< Server: xxxx
< Accept-Ranges: bytes
We can see Server field is printed twice. I need replace first one.
The “more_set_headers” of the “headers_more” module will work the way
that you expect now:
more_set_headers 'Server: xxxx';
Also, it applies to all the status code by default, unlike the
standard “headers” module. Use the -s option of the “more_set_headers”
directive if you want more control over it 
See GitHub - openresty/headers-more-nginx-module: Set, add, and clear arbitrary output headers in NGINX http servers for more
details.
Cheers,
-agentzh