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
136aae72
Commit
136aae72
authored
Aug 31, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Add --no-server-rewrite option not to rewrite server header field
parent
a60c3f89
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
3 deletions
+25
-3
gennghttpxfun.py
gennghttpxfun.py
+1
-0
src/shrpx.cc
src/shrpx.cc
+10
-0
src/shrpx_config.cc
src/shrpx_config.cc
+7
-0
src/shrpx_config.h
src/shrpx_config.h
+4
-0
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+1
-1
src/shrpx_https_upstream.cc
src/shrpx_https_upstream.cc
+1
-1
src/shrpx_spdy_upstream.cc
src/shrpx_spdy_upstream.cc
+1
-1
No files found.
gennghttpxfun.py
View file @
136aae72
...
@@ -135,6 +135,7 @@ OPTIONS = [
...
@@ -135,6 +135,7 @@ OPTIONS = [
"api-max-request-body"
,
"api-max-request-body"
,
"backend-max-backoff"
,
"backend-max-backoff"
,
"server-name"
,
"server-name"
,
"no-server-rewrite"
,
]
]
LOGVARS
=
[
LOGVARS
=
[
...
...
src/shrpx.cc
View file @
136aae72
...
@@ -2208,6 +2208,10 @@ HTTP:
...
@@ -2208,6 +2208,10 @@ HTTP:
--server-name=<NAME>
--server-name=<NAME>
Change server response header field value to <NAME>.
Change server response header field value to <NAME>.
Default: )"
<<
get_config
()
->
http
.
server_name
<<
R"(
Default: )"
<<
get_config
()
->
http
.
server_name
<<
R"(
--no-server-rewrite
Don't rewrite server header field in default mode. When
--http2-proxy is used, these headers will not be altered
regardless of this option.
API:
API:
--api-max-request-body=<SIZE>
--api-max-request-body=<SIZE>
...
@@ -2837,6 +2841,7 @@ int main(int argc, char **argv) {
...
@@ -2837,6 +2841,7 @@ int main(int argc, char **argv) {
{
SHRPX_OPT_API_MAX_REQUEST_BODY
.
c_str
(),
required_argument
,
&
flag
,
126
},
{
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_BACKEND_MAX_BACKOFF
.
c_str
(),
required_argument
,
&
flag
,
127
},
{
SHRPX_OPT_SERVER_NAME
.
c_str
(),
required_argument
,
&
flag
,
128
},
{
SHRPX_OPT_SERVER_NAME
.
c_str
(),
required_argument
,
&
flag
,
128
},
{
SHRPX_OPT_NO_SERVER_REWRITE
.
c_str
(),
no_argument
,
&
flag
,
129
},
{
nullptr
,
0
,
nullptr
,
0
}};
{
nullptr
,
0
,
nullptr
,
0
}};
int
option_index
=
0
;
int
option_index
=
0
;
...
@@ -3438,6 +3443,11 @@ int main(int argc, char **argv) {
...
@@ -3438,6 +3443,11 @@ int main(int argc, char **argv) {
// --server-name
// --server-name
cmdcfgs
.
emplace_back
(
SHRPX_OPT_SERVER_NAME
,
StringRef
{
optarg
});
cmdcfgs
.
emplace_back
(
SHRPX_OPT_SERVER_NAME
,
StringRef
{
optarg
});
break
;
break
;
case
129
:
// --no-server-rewrite
cmdcfgs
.
emplace_back
(
SHRPX_OPT_NO_SERVER_REWRITE
,
StringRef
::
from_lit
(
"yes"
));
break
;
default:
default:
break
;
break
;
}
}
...
...
src/shrpx_config.cc
View file @
136aae72
...
@@ -1288,6 +1288,9 @@ int option_lookup_token(const char *name, size_t namelen) {
...
@@ -1288,6 +1288,9 @@ int option_lookup_token(const char *name, size_t namelen) {
case
17
:
case
17
:
switch
(
name
[
16
])
{
switch
(
name
[
16
])
{
case
'e'
:
case
'e'
:
if
(
util
::
strieq_l
(
"no-server-rewrit"
,
name
,
16
))
{
return
SHRPX_OPTID_NO_SERVER_REWRITE
;
}
if
(
util
::
strieq_l
(
"worker-write-rat"
,
name
,
16
))
{
if
(
util
::
strieq_l
(
"worker-write-rat"
,
name
,
16
))
{
return
SHRPX_OPTID_WORKER_WRITE_RATE
;
return
SHRPX_OPTID_WORKER_WRITE_RATE
;
}
}
...
@@ -2682,6 +2685,10 @@ int parse_config(Config *config, int optid, const StringRef &opt,
...
@@ -2682,6 +2685,10 @@ int parse_config(Config *config, int optid, const StringRef &opt,
config
->
http
.
server_name
=
config
->
http
.
server_name
=
ImmutableString
{
std
::
begin
(
optarg
),
std
::
end
(
optarg
)};
ImmutableString
{
std
::
begin
(
optarg
),
std
::
end
(
optarg
)};
return
0
;
case
SHRPX_OPTID_NO_SERVER_REWRITE
:
config
->
http
.
no_server_rewrite
=
util
::
strieq_l
(
"yes"
,
optarg
);
return
0
;
return
0
;
case
SHRPX_OPTID_CONF
:
case
SHRPX_OPTID_CONF
:
LOG
(
WARN
)
<<
"conf: ignored"
;
LOG
(
WARN
)
<<
"conf: ignored"
;
...
...
src/shrpx_config.h
View file @
136aae72
...
@@ -285,6 +285,8 @@ constexpr auto SHRPX_OPT_API_MAX_REQUEST_BODY =
...
@@ -285,6 +285,8 @@ constexpr auto SHRPX_OPT_API_MAX_REQUEST_BODY =
constexpr
auto
SHRPX_OPT_BACKEND_MAX_BACKOFF
=
constexpr
auto
SHRPX_OPT_BACKEND_MAX_BACKOFF
=
StringRef
::
from_lit
(
"backend-max-backoff"
);
StringRef
::
from_lit
(
"backend-max-backoff"
);
constexpr
auto
SHRPX_OPT_SERVER_NAME
=
StringRef
::
from_lit
(
"server-name"
);
constexpr
auto
SHRPX_OPT_SERVER_NAME
=
StringRef
::
from_lit
(
"server-name"
);
constexpr
auto
SHRPX_OPT_NO_SERVER_REWRITE
=
StringRef
::
from_lit
(
"no-server-rewrite"
);
constexpr
size_t
SHRPX_OBFUSCATED_NODE_LENGTH
=
8
;
constexpr
size_t
SHRPX_OBFUSCATED_NODE_LENGTH
=
8
;
...
@@ -561,6 +563,7 @@ struct HttpConfig {
...
@@ -561,6 +563,7 @@ struct HttpConfig {
bool
no_via
;
bool
no_via
;
bool
no_location_rewrite
;
bool
no_location_rewrite
;
bool
no_host_rewrite
;
bool
no_host_rewrite
;
bool
no_server_rewrite
;
}
;
}
;
struct
Http2Config
{
struct
Http2Config
{
...
@@ -832,6 +835,7 @@ enum {
...
@@ -832,6 +835,7 @@ enum {
SHRPX_OPTID_NO_LOCATION_REWRITE
,
SHRPX_OPTID_NO_LOCATION_REWRITE
,
SHRPX_OPTID_NO_OCSP
,
SHRPX_OPTID_NO_OCSP
,
SHRPX_OPTID_NO_SERVER_PUSH
,
SHRPX_OPTID_NO_SERVER_PUSH
,
SHRPX_OPTID_NO_SERVER_REWRITE
,
SHRPX_OPTID_NO_VIA
,
SHRPX_OPTID_NO_VIA
,
SHRPX_OPTID_NPN_LIST
,
SHRPX_OPTID_NPN_LIST
,
SHRPX_OPTID_OCSP_UPDATE_INTERVAL
,
SHRPX_OPTID_OCSP_UPDATE_INTERVAL
,
...
...
src/shrpx_http2_upstream.cc
View file @
136aae72
...
@@ -1537,7 +1537,7 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream) {
...
@@ -1537,7 +1537,7 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream) {
http2
::
copy_headers_to_nva_nocopy
(
nva
,
resp
.
fs
.
headers
());
http2
::
copy_headers_to_nva_nocopy
(
nva
,
resp
.
fs
.
headers
());
if
(
!
get_config
()
->
http2_proxy
)
{
if
(
!
get_config
()
->
http2_proxy
&&
!
httpconf
.
no_server_rewrite
)
{
nva
.
push_back
(
nva
.
push_back
(
http2
::
make_nv_ls_nocopy
(
"server"
,
StringRef
{
httpconf
.
server_name
}));
http2
::
make_nv_ls_nocopy
(
"server"
,
StringRef
{
httpconf
.
server_name
}));
}
else
{
}
else
{
...
...
src/shrpx_https_upstream.cc
View file @
136aae72
...
@@ -1078,7 +1078,7 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream) {
...
@@ -1078,7 +1078,7 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream) {
}
}
}
}
if
(
!
get_config
()
->
http2_proxy
)
{
if
(
!
get_config
()
->
http2_proxy
&&
!
httpconf
.
no_server_rewrite
)
{
buf
->
append
(
"Server: "
);
buf
->
append
(
"Server: "
);
buf
->
append
(
httpconf
.
server_name
);
buf
->
append
(
httpconf
.
server_name
);
buf
->
append
(
"
\r\n
"
);
buf
->
append
(
"
\r\n
"
);
...
...
src/shrpx_spdy_upstream.cc
View file @
136aae72
...
@@ -1100,7 +1100,7 @@ int SpdyUpstream::on_downstream_header_complete(Downstream *downstream) {
...
@@ -1100,7 +1100,7 @@ int SpdyUpstream::on_downstream_header_complete(Downstream *downstream) {
nv
[
hdidx
++
]
=
hd
.
value
.
c_str
();
nv
[
hdidx
++
]
=
hd
.
value
.
c_str
();
}
}
if
(
!
get_config
()
->
http2_proxy
)
{
if
(
!
get_config
()
->
http2_proxy
&&
!
httpconf
.
no_server_rewrite
)
{
nv
[
hdidx
++
]
=
"server"
;
nv
[
hdidx
++
]
=
"server"
;
nv
[
hdidx
++
]
=
httpconf
.
server_name
.
c_str
();
nv
[
hdidx
++
]
=
httpconf
.
server_name
.
c_str
();
}
else
{
}
else
{
...
...
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