[PATCH] Resolver: added support for domain names with a trailing dot

Yichun Zhang (agentzh) agentzh at gmail.com
Fri Jan 10 20:13:26 UTC 2014


Hello!

On Fri, Jan 10, 2014 at 11:10 AM, Ruslan Ermilov wrote:
>
> There's no such thing as domain names with a trailing dot,
> with one exception of the root domain name.
>

Well, they are just a fully qualified domain names.

>
> So I must ask.  Why do you think that resolver in nginx
> should ever support names with a trailing dot?
>

Because our customers use things like "www.google.com." and expect it
to work like in their web browsers. And Nginx's resolver just returns
"Host not found" immediately.

>
> Regarding the patch, it would make more sense to strip the
> trailing dot once on entry, in ngx_resolve_name(), not in
> ngx_resolve_name_locked() which is also called internally.
>

Thank you for the suggestion! Attached the revised patch.

Thanks!
-agentzh

# HG changeset patch
# User Yichun Zhang <agentzh at gmail.com>
# Date 1389381734 28800
# Node ID 4b50d1f299d8a69f3e3f7975132e1490352642fe
# Parent  3d10680c0399cb8d2e3b601412df0495ffaab4a5
Resolver: added support for domain names with a trailing dot.

diff -r 3d10680c0399 -r 4b50d1f299d8 src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c Wed Jan 08 11:34:59 2014 -0800
+++ b/src/core/ngx_resolver.c Fri Jan 10 11:22:14 2014 -0800
@@ -356,6 +356,10 @@

     r = ctx->resolver;

+    if (ctx->name.len > 0 && ctx->name.data[ctx->name.len - 1] == '.') {
+        ctx->name.len--;
+    }
+
     ngx_log_debug1(NGX_LOG_DEBUG_CORE, r->log, 0,
                    "resolve: \"%V\"", &ctx->name);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: resolve-names-with-a-trailing-dot-V2.patch
Type: text/x-patch
Size: 696 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20140110/e1620fcf/attachment.bin>


More information about the nginx-devel mailing list