reverse proxy with dns control
Francis Daly
francis at daoine.org
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 (http://nginx.org/r/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 http://nginx.org/en/docs/http/request_processing.html, 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
good-name-three;
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,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list