So, I want to make dynamic proxy_pass
to vagrant machine on my server in .local zone controled by Avahi. I have a nginx virtual host configuration:
server {
listen 80;
server_name ~^(?<subdomain>.+)\.example\.com$;
location / {
resolver 127.0.0.1 valid=30s;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://$subdomain-example.local;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
}
}
Nginx have returned me an error in /var/log/nginx/error.log:
2016/09/26 18:03:34 [error] 24401#24401:
*1 no resolver defined to resolve test-example.local,
client: 192.168.1.101,
server: ~^(?<subdomain>.+)\.example\.com$,
request: "GET / HTTP/1.1",
host: "test.example.com"
But, if I manualy set $subdomain
to "test", for example, it's work and pass to test-example.local machine as I really want.
How to make it really dynamic? What I should change in my vhost configuration?