nginx配置如下
location = /cookie {
return 200 HTTP_COOKIE:$http_cookie\nHTTP_USER_AGENT:$http_user_agent\nARGS:$args\nCONTENT_LENGTH:$content_length\nCONTENT_TYPE:$content_type\nDOCUMENT_ROOT:$document_root\nHOST:$host\nLIMIT_TARE:$limit_rate\nREQUEST_METHOD:$request_method\nREMOTE_ADDR:$remote_addr\nREMOTE_PORT:$remote_port\nREMOTE_USER:$remote_user\nREQUEST_FILENAME:$request_filename\nSCHEME:$scheme\nSERVER_PROTOCOL:$server_protocol\nSERVER_ADDR:$server_addr\nSERVER_NAME:$server_name\nSERVER_PORT:$server_port\nREQUEST_URI:$request_uri\nURI:$uri\nDOCUMENT_URI:$document_uri\n;
}
curl请求及响应
$ curl -v --user admin:admin \
-H "Host:nginx.test.com" \
-A "user-agent-demo" \
--cookie "vrauth=someRandomValue;a=b" \
"http://10.86.0.110:8888/cookie?a=1&b=2"
* Trying 10.86.0.110...
* TCP_NODELAY set
* Connected to 10.86.0.110 (10.86.0.110) port 8888 (#0)
* Server auth using Basic with user 'admin'
> GET /cookie?a=1&b=2 HTTP/1.1
> Host:nginx.test.com
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: user-agent-demo
> Accept: */*
> Cookie: vrauth=someRandomValue;a=b
>
< HTTP/1.1 200 OK
< Server: nginx/1.12.2
< Date: Thu, 28 Jun 2018 08:29:17 GMT
< Content-Type: application/octet-stream
< Content-Length: 467
< Connection: keep-alive
<
HTTP_COOKIE:vrauth=someRandomValue;a=b
HTTP_USER_AGENT:user-agent-demo
ARGS:a=1&b=2
CONTENT_LENGTH:
CONTENT_TYPE:
DOCUMENT_ROOT:/export/servers/nginx/html
HOST:nginx.test.com
LIMIT_TARE:0
REQUEST_METHOD:GET
REMOTE_ADDR:10.86.1.24
REMOTE_PORT:52629
REMOTE_USER:admin
REQUEST_FILENAME:/export/servers/nginx/html/cookie
SCHEME:http
SERVER_PROTOCOL:HTTP/1.1
SERVER_ADDR:172.17.0.3
SERVER_NAME:_
SERVER_PORT:80
REQUEST_URI:/cookie?a=1&b=2
URI:/cookie
DOCUMENT_URI:/cookie
* Connection #0 to host 10.86.0.110 left intact
网友评论