Given the following location with proxy_pass, I want to log the fully qualified uri.
location ~* ^/?(foo/?.*$) {
proxy_pass https://www.someserver.com/some-thing-else/$1;
break;
}
So for example I'd like
https://www.originalserver.com/foo?page=5
to redirect to
https://www.someserver.com/some-thing-else/foo?page=5
which I believed to be working; I think something else later down the chain is dropping the query_string.
So I want to output to the log file exactly what it was passed to. I tried $uri, $proxy_host, and $upstream_addr but I couldn't find anything that would return the fully qualified uri
https://www.someserver.com/some-thing-else/foo?page=5
Instead I get:
proxy_host: www.someserver.com
upstream_addr: 123.45.67.890:443
uri_path: /foo
uri_query: page=5
I'm really new to rewrite rules, and coming from microsoft, so I've been reading the comprehensive docs for nginx and the searching the web, but I can't find an answer for this. Any help would be greatly appreciated. Thanks.
Addendum: this is the only rule of 7 where I'm running into issues.
Addendum Addendum: This is our current log format.
log_format json escape=json '{'
'"time_local": "$time_local",'
'"core": {'
'"site": "$server_name",'
'"server": "$host",'
'"dest_port": "$server_port",'
'"src_ip": "$realip_remote_addr",'
'"status": "$status",'
'"protocol": "$server_protocol",'
'"body_bytes_sent": "$body_bytes_sent",'
'"remote_addr": "$remote_addr",'
'"remote_user": "$remote_user",'
'"request": "$request",'
'"nginx_version": "$nginx_version",'
'"http": {'
'"http_referer": "$http_referer",'
'"http_user_agent": "$http_user_agent",'
'"http_x_header": "$http_x_header",'
'"uri_query": "$query_string",'
'"uri_path": "$uri",'
'"http_method": "$request_method",'
'"response_time": "$upstream_response_time",'
'"cookie": "$http_cookie",'
'"request_time": "$request_time",'
'"http_x_forwarded_for":
'"$http_x_forwarded_for",'
'"proxy_host": "$proxy_host",'
'"upstream_addr": "$upstream_addr"'
'}'
'}'
'}';```