Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
0d4d1a63
Commit
0d4d1a63
authored
Aug 26, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Add --server-name option to change server response header field
parent
833cd962
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
7 deletions
+33
-7
gennghttpxfun.py
gennghttpxfun.py
+1
-0
src/memchunk.h
src/memchunk.h
+3
-0
src/shrpx.cc
src/shrpx.cc
+9
-1
src/shrpx_config.cc
src/shrpx_config.cc
+10
-0
src/shrpx_config.h
src/shrpx_config.h
+3
-1
src/shrpx_http.cc
src/shrpx_http.cc
+1
-1
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+6
-4
No files found.
gennghttpxfun.py
View file @
0d4d1a63
...
...
@@ -134,6 +134,7 @@ OPTIONS = [
"backend-http2-settings-timeout"
,
"api-max-request-body"
,
"backend-max-backoff"
,
"server-name"
,
]
LOGVARS
=
[
...
...
src/memchunk.h
View file @
0d4d1a63
...
...
@@ -178,6 +178,9 @@ template <typename Memchunk> struct Memchunks {
}
size_t
append
(
const
std
::
string
&
s
)
{
return
append
(
s
.
c_str
(),
s
.
size
());
}
size_t
append
(
const
StringRef
&
s
)
{
return
append
(
s
.
c_str
(),
s
.
size
());
}
size_t
append
(
const
ImmutableString
&
s
)
{
return
append
(
s
.
c_str
(),
s
.
size
());
}
size_t
remove
(
void
*
dest
,
size_t
count
)
{
if
(
!
tail
||
count
==
0
)
{
return
0
;
...
...
src/shrpx.cc
View file @
0d4d1a63
...
...
@@ -1317,7 +1317,7 @@ void fill_default_config(Config *config) {
auto
&
httpconf
=
config
->
http
;
httpconf
.
server_name
=
StringRef
::
from_lit
(
"nghttpx nghttp2/"
NGHTTP2_VERSION
);
ImmutableString
::
from_lit
(
"nghttpx nghttp2/"
NGHTTP2_VERSION
);
httpconf
.
no_host_rewrite
=
true
;
httpconf
.
request_header_field_buffer
=
64
_k
;
httpconf
.
max_request_header_fields
=
100
;
...
...
@@ -2203,6 +2203,9 @@ HTTP:
599. If "*" is used instead of <CODE>, it matches all
HTTP status code. If error status code comes from
backend server, the custom error pages are not used.
--server-name=<NAME>
Change server response header field value to <NAME>.
Default: )"
<<
get_config
()
->
http
.
server_name
<<
R"(
API:
--api-max-request-body=<SIZE>
...
...
@@ -2831,6 +2834,7 @@ int main(int argc, char **argv) {
&
flag
,
125
},
{
SHRPX_OPT_API_MAX_REQUEST_BODY
.
c_str
(),
required_argument
,
&
flag
,
126
},
{
SHRPX_OPT_BACKEND_MAX_BACKOFF
.
c_str
(),
required_argument
,
&
flag
,
127
},
{
SHRPX_OPT_SERVER_NAME
.
c_str
(),
required_argument
,
&
flag
,
128
},
{
nullptr
,
0
,
nullptr
,
0
}};
int
option_index
=
0
;
...
...
@@ -3428,6 +3432,10 @@ int main(int argc, char **argv) {
// --backend-max-backoff
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_MAX_BACKOFF
,
StringRef
{
optarg
});
break
;
case
128
:
// --server-name
cmdcfgs
.
emplace_back
(
SHRPX_OPT_SERVER_NAME
,
StringRef
{
optarg
});
break
;
default:
break
;
}
...
...
src/shrpx_config.cc
View file @
0d4d1a63
...
...
@@ -1127,6 +1127,11 @@ int option_lookup_token(const char *name, size_t namelen) {
break
;
case
11
:
switch
(
name
[
10
])
{
case
'e'
:
if
(
util
::
strieq_l
(
"server-nam"
,
name
,
10
))
{
return
SHRPX_OPTID_SERVER_NAME
;
}
break
;
case
's'
:
if
(
util
::
strieq_l
(
"backend-tl"
,
name
,
10
))
{
return
SHRPX_OPTID_BACKEND_TLS
;
...
...
@@ -2673,6 +2678,11 @@ int parse_config(Config *config, int optid, const StringRef &opt,
case
SHRPX_OPTID_BACKEND_MAX_BACKOFF
:
return
parse_duration
(
&
config
->
conn
.
downstream
->
timeout
.
max_backoff
,
opt
,
optarg
);
case
SHRPX_OPTID_SERVER_NAME
:
config
->
http
.
server_name
=
ImmutableString
{
std
::
begin
(
optarg
),
std
::
end
(
optarg
)};
return
0
;
case
SHRPX_OPTID_CONF
:
LOG
(
WARN
)
<<
"conf: ignored"
;
...
...
src/shrpx_config.h
View file @
0d4d1a63
...
...
@@ -284,6 +284,7 @@ constexpr auto SHRPX_OPT_API_MAX_REQUEST_BODY =
StringRef
::
from_lit
(
"api-max-request-body"
);
constexpr
auto
SHRPX_OPT_BACKEND_MAX_BACKOFF
=
StringRef
::
from_lit
(
"backend-max-backoff"
);
constexpr
auto
SHRPX_OPT_SERVER_NAME
=
StringRef
::
from_lit
(
"server-name"
);
constexpr
size_t
SHRPX_OBFUSCATED_NODE_LENGTH
=
8
;
...
...
@@ -552,7 +553,7 @@ struct HttpConfig {
std
::
vector
<
ErrorPage
>
error_pages
;
Headers
add_request_headers
;
Headers
add_response_headers
;
StringRef
server_name
;
ImmutableString
server_name
;
size_t
request_header_field_buffer
;
size_t
max_request_header_fields
;
size_t
response_header_field_buffer
;
...
...
@@ -843,6 +844,7 @@ enum {
SHRPX_OPTID_REQUEST_HEADER_FIELD_BUFFER
,
SHRPX_OPTID_RESPONSE_HEADER_FIELD_BUFFER
,
SHRPX_OPTID_RLIMIT_NOFILE
,
SHRPX_OPTID_SERVER_NAME
,
SHRPX_OPTID_STREAM_READ_TIMEOUT
,
SHRPX_OPTID_STREAM_WRITE_TIMEOUT
,
SHRPX_OPTID_STRIP_INCOMING_FORWARDED
,
...
...
src/shrpx_http.cc
View file @
0d4d1a63
...
...
@@ -51,7 +51,7 @@ StringRef create_error_html(BlockAllocator &balloc, unsigned int http_status) {
return
concat_string_ref
(
balloc
,
StringRef
::
from_lit
(
R"(<!DOCTYPE html><html lang="en"><title>)"
),
status_string
,
StringRef
::
from_lit
(
"</title><body><h1>"
),
status_string
,
StringRef
::
from_lit
(
"</h1><footer>"
),
server_name
,
StringRef
::
from_lit
(
"</h1><footer>"
),
StringRef
{
server_name
}
,
StringRef
::
from_lit
(
"</footer></body></html>"
));
}
...
...
src/shrpx_http2_upstream.cc
View file @
0d4d1a63
...
...
@@ -1307,8 +1307,8 @@ int Http2Upstream::send_reply(Downstream *downstream, const uint8_t *body,
}
if
(
!
resp
.
fs
.
header
(
http2
::
HD_SERVER
))
{
nva
.
push_back
(
http2
::
make_nv_ls_nocopy
(
"server"
,
get_config
()
->
http
.
server_name
));
nva
.
push_back
(
http2
::
make_nv_ls_nocopy
(
"server"
,
StringRef
{
get_config
()
->
http
.
server_name
}
));
}
for
(
auto
&
p
:
httpconf
.
add_response_headers
)
{
...
...
@@ -1359,7 +1359,8 @@ int Http2Upstream::error_reply(Downstream *downstream,
auto
nva
=
std
::
array
<
nghttp2_nv
,
5
>
{
{
http2
::
make_nv_ls_nocopy
(
":status"
,
response_status
),
http2
::
make_nv_ll
(
"content-type"
,
"text/html; charset=UTF-8"
),
http2
::
make_nv_ls_nocopy
(
"server"
,
get_config
()
->
http
.
server_name
),
http2
::
make_nv_ls_nocopy
(
"server"
,
StringRef
{
get_config
()
->
http
.
server_name
}),
http2
::
make_nv_ls_nocopy
(
"content-length"
,
content_length
),
http2
::
make_nv_ls_nocopy
(
"date"
,
date
)}};
...
...
@@ -1506,7 +1507,8 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream) {
http2
::
copy_headers_to_nva_nocopy
(
nva
,
resp
.
fs
.
headers
());
if
(
!
get_config
()
->
http2_proxy
)
{
nva
.
push_back
(
http2
::
make_nv_ls_nocopy
(
"server"
,
httpconf
.
server_name
));
nva
.
push_back
(
http2
::
make_nv_ls_nocopy
(
"server"
,
StringRef
{
httpconf
.
server_name
}));
}
else
{
auto
server
=
resp
.
fs
.
header
(
http2
::
HD_SERVER
);
if
(
server
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment