I am seeing very slow DNS lookup times ( > 2 seconds ) using proxy_pass, even though dig response times on the server are quick. Here is the nginx configuration block:
location ~ ^/v1/(?<url>.*) {
resolver 8.8.4.4 4.4.4.4 valid=300s;
resolver_timeout 10s;
proxy_pass https://$remote_user.mydomain.com/api/;
proxy_hide_header Vary;
proxy_set_header X-Real-IP $remote_addr;
proxy_connect_timeout 10s;
proxy_read_timeout 60s;
proxy_ssl_session_reuse on;
}
I am using Google Public DNS. Here is a result from: dig demo.mydomain.com
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> demo.mydomain.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37997
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;demo.mydomain.com. IN A
;; ANSWER SECTION:
demo.mydomain.com. 299 IN A X.X.X.X
;; Query time: 187 msec
;; SERVER: 8.8.4.4#53(8.8.4.4)
;; WHEN: Fri Jan 3 19:40:32 2014
;; MSG SIZE rcvd: 50
Any ideas why this is so slow, and solutions?