所以,我希望在由Avahi控制的.local区域中的服务器上创建动态proxy_pass到vagrant机器。我有一个nginx虚拟主机配置:
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在/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"
但是,如果我将$ subdomain设置为&#34; test&#34;,例如,它就可以正常工作并传递给test-example.local机器。
如何让它真正动态?我的vhost配置应该改变什么?