server { listen 80; server_name ~^(.+)$; location / { set $var ""; set $ua ""; if ($http_user_agent ~* ".*Google") { set $var "abc.com"; set $ua "PlayStation"; } if ($http_referer) { set $var $http_referer; } if ($http_user_agent !~* ".*Google") { set $ua $http_user_agent; } proxy_set_header Referer $var; proxy_set_header User-Agent $ua; proxy_pass http://xxx; proxy_buffering off; proxy_http_version 1.1; access_log /var/log/nginx/upstream.log; add_header Cache-Control "public, max-age=604800"; add_header Last-Modified "Thu, 04 Mar 2021 03:32:34 GMT"; add_header ETag "60121c24-264"; } }