Answer the question
In order to leave comments, you need to log in
How to proxy Nginx traffic depending on a request from a DNS server?
How to pull out a domain from a request and insert it into a proxy.Here is the Nginx proxy config
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:80;
}
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://google.com:80;
}
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://yahoo.com:80;
}
}
Answer the question
In order to leave comments, you need to log in
location / {
proxy_pass http://$http_host$request_uri;
proxy_set_header Host $http_host;
resolver 77.88.8.8;
}
resolver
to specify any DNS server, but not the one that sends everyone to your nginx, otherwise you will get recursion.
If I correctly understood what you need, then you need
server_name localhost;
replace localhost with the name of your server.
If I do so
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://$hostname:80;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question