Hi,
on http://wiki.nginx.org/HttpCoreModule#server_name i read about
capturing
the servername with regular expressions. Now i used the following on
nginx
0.9.2:
server {
listen [::]:80 default ipv6only=off;
server_name ~^(?.+).internal.mydomain.tld$;
location / {
proxy_pass http://1.2.3.4:80;
proxy_set_header Host $domain;
}
}
but Host is not set at all on the upstream, because it seems that nginx
doesn’t get it captured. The regexp matches, i also tried with
?P
as stated on the page with no success. Anything i’m doing wrong here?
Thanks and regards,
Sven
On Sun, Dec 12, 2010 at 07:26:23PM +0100, Sven ‘Darkman’ Michels wrote:
location / {
proxy_pass http://1.2.3.4:80;
proxy_set_header Host $domain;
}
}
but Host is not set at all on the upstream, because it seems that nginx
doesn’t get it captured. The regexp matches, i also tried with ?P
as stated on the page with no success. Anything i’m doing wrong here?
If you run nginx with debug log:
http://nginx.org/en/docs/debugging_log.html
you should see something like this:
http header: “Host: www.internal.mydonain.tld”
…
http regex set $domain to “www”
–
Igor S.
http://sysoev.ru/en/
Hi,
thanks for the quick reply.
Am 12.12.2010 19:58, schrieb Igor S.:
If you run nginx with debug log:
A debugging log
you should see something like this:
http header: “Host: www.internal.mydonain.tld”
…
http regex set $domain to “www”
ok, debbuging enabled, but nothing with “regex” shows up. I’m getting
2010/12/12 20:10:37 [debug] 32080#0: *1 http header: “Host:
www.internal.mydomain.tld”
2010/12/12 20:10:37 [debug] 32080#0: *1 http header done
which seems to be ok so far, but no regex matching somewhere…
Is there a need of some compiling options? nginx itself is liked against
pcre lib, so it looks ok so far for me…
Regards,
Sven
Hi,
Am 12.12.2010 20:35, schrieb Igor S.:
ok, debbuging enabled, but nothing with “regex” shows up. I’m getting
2010/12/12 20:10:37 [debug] 32080#0: *1 http header: “Host:
www.internal.mydomain.tld”
2010/12/12 20:10:37 [debug] 32080#0: *1 http header done
which seems to be ok so far, but no regex matching somewhere…
Is there a need of some compiling options? nginx itself is liked against
pcre lib, so it looks ok so far for me…
Do you request nginx via ipv4 or ipv6 ?
mh, normally v6 but i tried with v4 now, looks the same (its dualstack).
Regards,
Sven
On Sun, Dec 12, 2010 at 08:22:09PM +0100, Sven ‘Darkman’ Michels wrote:
…
http regex set $domain to “www”
ok, debbuging enabled, but nothing with “regex” shows up. I’m getting
2010/12/12 20:10:37 [debug] 32080#0: *1 http header: “Host:
www.internal.mydomain.tld”
2010/12/12 20:10:37 [debug] 32080#0: *1 http header done
which seems to be ok so far, but no regex matching somewhere…
Is there a need of some compiling options? nginx itself is liked against
pcre lib, so it looks ok so far for me…
Do you request nginx via ipv4 or ipv6 ?
–
Igor S.
http://sysoev.ru/en/
On Sun, Dec 12, 2010 at 08:43:41PM +0100, Sven ‘Darkman’ Michels wrote:
pcre lib, so it looks ok so far for me…
Do you request nginx via ipv4 or ipv6 ?
mh, normally v6 but i tried with v4 now, looks the same (its dualstack).
Do you have other servers in configuration ?
–
Igor S.
http://sysoev.ru/en/
Hi,
Am 12.12.2010 20:48, schrieb Igor S.:
mh, normally v6 but i tried with v4 now, looks the same (its dualstack).
Do you have other servers in configuration ?
plenty but i got it. You’re right with the v4/v6 thing. It works if i
use v4
only (e.g. just a “listen 80;” in the config). So i would say its a bug?
Regards,
Sven
Hi,
Am 12.12.2010 20:59, schrieb Igor S.:
plenty but i got it. You’re right with the v4/v6 thing. It works if i use v4
only (e.g. just a “listen 80;” in the config). So i would say its a bug?
Do you have “listen” directives with specific addresses ?
How do other “listen” directives look ?
nope, its just a very small test config.
works:
server {
listen 80;
server_name ~^(?.+).internal.mydomain.tld$;
…
}
doesn’t:
server {
listen [::]:80 default ipv6only=off;
server_name ~^(?.+).internal.mydomain.tld$;
…
}
nothing else changed.
HTH,
Sven
On Sun, Dec 12, 2010 at 08:54:04PM +0100, Sven ‘Darkman’ Michels wrote:
Hi,
Am 12.12.2010 20:48, schrieb Igor S.:
mh, normally v6 but i tried with v4 now, looks the same (its dualstack).
Do you have other servers in configuration ?
plenty but i got it. You’re right with the v4/v6 thing. It works if i use v4
only (e.g. just a “listen 80;” in the config). So i would say its a bug?
Do you have “listen” directives with specific addresses ?
How do other “listen” directives look ?
–
Igor S.
http://sysoev.ru/en/
On Sun, Dec 12, 2010 at 09:05:49PM +0100, Sven ‘Darkman’ Michels wrote:
server_name ~^(?<domain>.+)\.internal\.mydomain\.tld$;
…
}
nothing else changed.
The attached patch should fix the bug.
Hi!
Am 12.12.2010 21:45, schrieb Igor S.:
The attached patch should fix the bug.
tested it today, and yes, it seems to fix the problem
At least all my
tests
did succeed. Thanks for the quick fix!
Regards,
Sven
Hi,
Am 12.12.2010 21:45, schrieb Igor S.:
server {
listen [::]:80 default ipv6only=off;
server_name ~^(?.+).internal.mydomain.tld$;
…
}
nothing else changed.
The attached patch should fix the bug.
Ok, will try tomorrow (haven’t time right now, hopefully tomorrow), but
thanks a lot for this quick fix. I’ll report back!
Regards,
Sven