nginx.confに/hoge$is_args$args;
と書いているものがある。
$is_argsとはリクエスト行に引数がある場合は?となり、引数なしの時は空文字列になる。
↓確認
nginx.conf
location / {
add_header hoge is_args=${is_args};
}
$ curl -I localhost
HTTP/1.1 200 OK
Server: nginx/1.14.1
Date: Fri, 11 Dec 2020 16:46:06 GMT
Content-Type: text/html
Content-Length: 4057
Last-Modified: Mon, 07 Oct 2019 21:16:24 GMT
Connection: keep-alive
ETag: "5d9bab28-fd9"
hoge: is_args= * 空文字になっている
Accept-Ranges: bytes
$ curl -I localhost?hoge=fuga
HTTP/1.1 200 OK
Server: nginx/1.14.1
Date: Fri, 11 Dec 2020 16:46:32 GMT
Content-Type: text/html
Content-Length: 4057
Last-Modified: Mon, 07 Oct 2019 21:16:24 GMT
Connection: keep-alive
ETag: "5d9bab28-fd9"
hoge: is_args=? * はてながついてる
Accept-Ranges: bytes
$argsとはurlに書かれたgetパラメータのこと
↓確認
nginx.conf
location / {
add_header hoge is_args=${is_args}${args};
}
$ curl -I localhost
HTTP/1.1 200 OK
Server: nginx/1.14.1
Date: Fri, 11 Dec 2020 16:51:17 GMT
Content-Type: text/html
Content-Length: 4057
Last-Modified: Mon, 07 Oct 2019 21:16:24 GMT
Connection: keep-alive
ETag: "5d9bab28-fd9"
hoge: is_args=
Accept-Ranges: bytes
$ curl -I localhost?a=b
HTTP/1.1 200 OK
Server: nginx/1.14.1
Date: Fri, 11 Dec 2020 16:51:32 GMT
Content-Type: text/html
Content-Length: 4057
Last-Modified: Mon, 07 Oct 2019 21:16:24 GMT
Connection: keep-alive
ETag: "5d9bab28-fd9"
hoge: is_args=?a=b
Accept-Ranges: bytes
curl -I localhost?a=b&c=d
[1] 644
[root@ebe2eb08b5b2 ~]# HTTP/1.1 200 OK
Server: nginx/1.14.1
Date: Fri, 11 Dec 2020 16:51:47 GMT
Content-Type: text/html
Content-Length: 4057
Last-Modified: Mon, 07 Oct 2019 21:16:24 GMT
Connection: keep-alive
ETag: "5d9bab28-fd9"
hoge: is_args=?a=b * あれc=dが消えてる・・・?
Accept-Ranges: bytes
localhost?a=b&c=dの時にargsにc=dのデータが入らないのが気になる。。。