reverse proxy with dns control

Francis Daly francis at
Thu Apr 14 12:26:19 UTC 2022

On Thu, Apr 14, 2022 at 07:02:28AM -0400, arx wrote:

Hi there,

> the important thing for me is the dns, the port is static and no server do
> the check,
> the problem that I don't know how it is calls the variable with what name
> the client makes the request (the dns that is invoked in the GET method by
> the client) present in access.log
> [14/Apr/2022:12:22:57 +0200] "GET /favicon.ico HTTP/1.1" 404 548
> "http://DNS:PORT/" "Mozilla/5.0 (........

log_format ( describes what is written to
access.log (access_log on the same page).

The part you mention there is $http_referer; but you probably want to use
$host. See, so that
you do not have to use $host.

> I have to check on dns, and when I go to put the condition (as in the
> previous example it gives me a syntax error)

I believe you will be much happier if you do something like

  server {
    listen port;
    server_name good-name-one good-name-two

    location / {
      # proxy_pass or whatever is wanted. For testing:
      return 200 "Ok - host $host is allowed\n";
  server {
    listen port default_server;
    return 200 "No - host $host is not allowed\n";

where "port" is changed to the correct number in each case.

Set the "good names" that you want to allow, and see that you get the
"no" or "ok" message for the different names that you test.

And then change the "return" lines to do what you want.

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list