Nginx request port

Solution 1:

Hopefully not too little too (eight months!) late. I had a similar question myself, to use the original request port in nginx.conf.

nginx $http_name variable

$http_name: arbitrary request header field; the last part of a variable name is the field name converted to lower case with dashes replaced by underscores

$http_host should therefore contain the request 'Host' header, if that helps.

e.g. localhost:8020