Mercurial > hg > nginx-quic
annotate src/core/ngx_resolver.h @ 6227:bd55d75a1410
Fixed wrong URI after try_files in nested location (ticket #97).
The following configuration with alias, nested location and try_files
resulted in wrong file being used. Request "/foo/test.gif" tried to
use "/tmp//foo/test.gif" instead of "/tmp/test.gif":
location /foo/ {
alias /tmp/;
location ~ gif {
try_files $uri =405;
}
}
Additionally, rev. c985d90a8d1f introduced a regression if
the "/tmp//foo/test.gif" file was found (ticket #768). Resulting URI
was set to "gif?/foo/test.gif", as the code used clcf->name of current
location ("location ~ gif") instead of parent one ("location /foo/").
Fix is to use r->uri instead of clcf->name in all cases in the
ngx_http_core_try_files_phase() function. It is expected to be
already matched and identical to the clcf->name of the right
location.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sun, 16 Aug 2015 10:51:34 +0300 |
parents | 5004210e8c78 |
children | 7316c57e4fe7 |
rev | line source |
---|---|
1649 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4412 | 4 * Copyright (C) Nginx, Inc. |
1649 | 5 */ |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 | |
11 | |
12 #ifndef _NGX_RESOLVER_H_INCLUDED_ | |
13 #define _NGX_RESOLVER_H_INCLUDED_ | |
14 | |
15 | |
16 #define NGX_RESOLVE_A 1 | |
17 #define NGX_RESOLVE_CNAME 5 | |
18 #define NGX_RESOLVE_PTR 12 | |
19 #define NGX_RESOLVE_MX 15 | |
20 #define NGX_RESOLVE_TXT 16 | |
5477
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
21 #if (NGX_HAVE_INET6) |
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
22 #define NGX_RESOLVE_AAAA 28 |
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
23 #endif |
1965 | 24 #define NGX_RESOLVE_DNAME 39 |
1649 | 25 |
26 #define NGX_RESOLVE_FORMERR 1 | |
27 #define NGX_RESOLVE_SERVFAIL 2 | |
28 #define NGX_RESOLVE_NXDOMAIN 3 | |
29 #define NGX_RESOLVE_NOTIMP 4 | |
30 #define NGX_RESOLVE_REFUSED 5 | |
31 #define NGX_RESOLVE_TIMEDOUT NGX_ETIMEDOUT | |
32 | |
33 | |
1683
1e0b028055ec
allow to use IP addresses without defined resolver
Igor Sysoev <igor@sysoev.ru>
parents:
1649
diff
changeset
|
34 #define NGX_NO_RESOLVER (void *) -1 |
1e0b028055ec
allow to use IP addresses without defined resolver
Igor Sysoev <igor@sysoev.ru>
parents:
1649
diff
changeset
|
35 |
1969 | 36 #define NGX_RESOLVER_MAX_RECURSION 50 |
37 | |
1683
1e0b028055ec
allow to use IP addresses without defined resolver
Igor Sysoev <igor@sysoev.ru>
parents:
1649
diff
changeset
|
38 |
1649 | 39 typedef struct { |
40 ngx_connection_t *connection; | |
41 struct sockaddr *sockaddr; | |
42 socklen_t socklen; | |
43 ngx_str_t server; | |
3408
71193a456616
add context to a resolver log
Igor Sysoev <igor@sysoev.ru>
parents:
3269
diff
changeset
|
44 ngx_log_t log; |
1649 | 45 } ngx_udp_connection_t; |
46 | |
47 | |
48 typedef struct ngx_resolver_ctx_s ngx_resolver_ctx_t; | |
49 | |
50 typedef void (*ngx_resolver_handler_pt)(ngx_resolver_ctx_t *ctx); | |
51 | |
52 | |
53 typedef struct { | |
5921
5004210e8c78
Resolver: fixed debug event logging.
Ruslan Ermilov <ru@nginx.com>
parents:
5478
diff
changeset
|
54 /* PTR: resolved name, A: name to resolve */ |
5004210e8c78
Resolver: fixed debug event logging.
Ruslan Ermilov <ru@nginx.com>
parents:
5478
diff
changeset
|
55 u_char *name; |
5004210e8c78
Resolver: fixed debug event logging.
Ruslan Ermilov <ru@nginx.com>
parents:
5478
diff
changeset
|
56 |
1649 | 57 ngx_queue_t queue; |
58 | |
5921
5004210e8c78
Resolver: fixed debug event logging.
Ruslan Ermilov <ru@nginx.com>
parents:
5478
diff
changeset
|
59 /* event ident must be after 3 pointers as in ngx_connection_t */ |
5004210e8c78
Resolver: fixed debug event logging.
Ruslan Ermilov <ru@nginx.com>
parents:
5478
diff
changeset
|
60 ngx_int_t ident; |
5004210e8c78
Resolver: fixed debug event logging.
Ruslan Ermilov <ru@nginx.com>
parents:
5478
diff
changeset
|
61 |
5004210e8c78
Resolver: fixed debug event logging.
Ruslan Ermilov <ru@nginx.com>
parents:
5478
diff
changeset
|
62 ngx_rbtree_node_t node; |
1649 | 63 |
5476
950c9ed3e66f
Resolver: implemented IPv6 address to name resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5475
diff
changeset
|
64 #if (NGX_HAVE_INET6) |
950c9ed3e66f
Resolver: implemented IPv6 address to name resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5475
diff
changeset
|
65 /* PTR: IPv6 address to resolve (IPv4 address is in rbtree node key) */ |
950c9ed3e66f
Resolver: implemented IPv6 address to name resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5475
diff
changeset
|
66 struct in6_addr addr6; |
950c9ed3e66f
Resolver: implemented IPv6 address to name resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5475
diff
changeset
|
67 #endif |
950c9ed3e66f
Resolver: implemented IPv6 address to name resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5475
diff
changeset
|
68 |
1649 | 69 u_short nlen; |
70 u_short qlen; | |
71 | |
72 u_char *query; | |
5477
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
73 #if (NGX_HAVE_INET6) |
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
74 u_char *query6; |
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
75 #endif |
1649 | 76 |
77 union { | |
78 in_addr_t addr; | |
79 in_addr_t *addrs; | |
80 u_char *cname; | |
81 } u; | |
82 | |
5477
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
83 u_char code; |
1649 | 84 u_short naddrs; |
85 u_short cnlen; | |
86 | |
5477
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
87 #if (NGX_HAVE_INET6) |
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
88 union { |
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
89 struct in6_addr addr6; |
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
90 struct in6_addr *addrs6; |
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
91 } u6; |
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
92 |
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
93 u_short naddrs6; |
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
94 #endif |
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
95 |
1649 | 96 time_t expire; |
97 time_t valid; | |
5477
98876ce2a7fd
Resolver: implemented IPv6 name to address resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5476
diff
changeset
|
98 uint32_t ttl; |
1649 | 99 |
100 ngx_resolver_ctx_t *waiting; | |
101 } ngx_resolver_node_t; | |
102 | |
103 | |
104 typedef struct { | |
105 /* has to be pointer because of "incomplete type" */ | |
106 ngx_event_t *event; | |
4225
016352c19049
Support of several servers in the "resolver" directive.
Igor Sysoev <igor@sysoev.ru>
parents:
3408
diff
changeset
|
107 void *dummy; |
1649 | 108 ngx_log_t *log; |
109 | |
5921
5004210e8c78
Resolver: fixed debug event logging.
Ruslan Ermilov <ru@nginx.com>
parents:
5478
diff
changeset
|
110 /* event ident must be after 3 pointers as in ngx_connection_t */ |
1649 | 111 ngx_int_t ident; |
112 | |
4225
016352c19049
Support of several servers in the "resolver" directive.
Igor Sysoev <igor@sysoev.ru>
parents:
3408
diff
changeset
|
113 /* simple round robin DNS peers balancer */ |
016352c19049
Support of several servers in the "resolver" directive.
Igor Sysoev <igor@sysoev.ru>
parents:
3408
diff
changeset
|
114 ngx_array_t udp_connections; |
016352c19049
Support of several servers in the "resolver" directive.
Igor Sysoev <igor@sysoev.ru>
parents:
3408
diff
changeset
|
115 ngx_uint_t last_connection; |
016352c19049
Support of several servers in the "resolver" directive.
Igor Sysoev <igor@sysoev.ru>
parents:
3408
diff
changeset
|
116 |
1649 | 117 ngx_rbtree_t name_rbtree; |
118 ngx_rbtree_node_t name_sentinel; | |
119 | |
120 ngx_rbtree_t addr_rbtree; | |
121 ngx_rbtree_node_t addr_sentinel; | |
122 | |
123 ngx_queue_t name_resend_queue; | |
124 ngx_queue_t addr_resend_queue; | |
125 | |
126 ngx_queue_t name_expire_queue; | |
127 ngx_queue_t addr_expire_queue; | |
128 | |
5476
950c9ed3e66f
Resolver: implemented IPv6 address to name resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5475
diff
changeset
|
129 #if (NGX_HAVE_INET6) |
5478
3cb3175a6fef
The "ipv6=" boolean parameter of the "resolver" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
5477
diff
changeset
|
130 ngx_uint_t ipv6; /* unsigned ipv6:1; */ |
5476
950c9ed3e66f
Resolver: implemented IPv6 address to name resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5475
diff
changeset
|
131 ngx_rbtree_t addr6_rbtree; |
950c9ed3e66f
Resolver: implemented IPv6 address to name resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5475
diff
changeset
|
132 ngx_rbtree_node_t addr6_sentinel; |
950c9ed3e66f
Resolver: implemented IPv6 address to name resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5475
diff
changeset
|
133 ngx_queue_t addr6_resend_queue; |
950c9ed3e66f
Resolver: implemented IPv6 address to name resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5475
diff
changeset
|
134 ngx_queue_t addr6_expire_queue; |
950c9ed3e66f
Resolver: implemented IPv6 address to name resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5475
diff
changeset
|
135 #endif |
950c9ed3e66f
Resolver: implemented IPv6 address to name resolving.
Ruslan Ermilov <ru@nginx.com>
parents:
5475
diff
changeset
|
136 |
1649 | 137 time_t resend_timeout; |
138 time_t expire; | |
139 time_t valid; | |
140 | |
141 ngx_uint_t log_level; | |
142 } ngx_resolver_t; | |
143 | |
144 | |
145 struct ngx_resolver_ctx_s { | |
146 ngx_resolver_ctx_t *next; | |
147 ngx_resolver_t *resolver; | |
148 ngx_udp_connection_t *udp_connection; | |
149 | |
150 ngx_int_t state; | |
151 ngx_str_t name; | |
152 | |
153 ngx_uint_t naddrs; | |
5475
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
154 ngx_addr_t *addrs; |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
155 ngx_addr_t addr; |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
156 struct sockaddr_in sin; |
1649 | 157 |
158 ngx_resolver_handler_pt handler; | |
159 void *data; | |
160 ngx_msec_t timeout; | |
161 | |
162 ngx_uint_t quick; /* unsigned quick:1; */ | |
1969 | 163 ngx_uint_t recursion; |
1649 | 164 ngx_event_t *event; |
165 }; | |
166 | |
167 | |
4225
016352c19049
Support of several servers in the "resolver" directive.
Igor Sysoev <igor@sysoev.ru>
parents:
3408
diff
changeset
|
168 ngx_resolver_t *ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, |
016352c19049
Support of several servers in the "resolver" directive.
Igor Sysoev <igor@sysoev.ru>
parents:
3408
diff
changeset
|
169 ngx_uint_t n); |
1649 | 170 ngx_resolver_ctx_t *ngx_resolve_start(ngx_resolver_t *r, |
171 ngx_resolver_ctx_t *temp); | |
172 ngx_int_t ngx_resolve_name(ngx_resolver_ctx_t *ctx); | |
173 void ngx_resolve_name_done(ngx_resolver_ctx_t *ctx); | |
174 ngx_int_t ngx_resolve_addr(ngx_resolver_ctx_t *ctx); | |
175 void ngx_resolve_addr_done(ngx_resolver_ctx_t *ctx); | |
176 char *ngx_resolver_strerror(ngx_int_t err); | |
177 | |
178 | |
179 #endif /* _NGX_RESOLVER_H_INCLUDED_ */ |