Welcome! Log In Create A New Profile

Advanced

URL special characters, punycode and http

Posted by Dzhalagash 
URL special characters, punycode and http
March 13, 2014 07:16AM
I have a URL with special carachters (nicolòzanetti.com), and I'm having problem telling nginx how to handle it to the correct site.

With a basic configuration:
server_name www.nicolòzanetti.com nicolòzanetti.com;
https://www.nicolòzanetti.com -> Default virtual host but url unchanged
https://nicolòzanetti.com -> Default virtual host but url unchanged
http://www.nicolòzanetti.com -> Default virtual host and url changed to that of default virtual host
http://nicolòzanetti.com -> Default virtual host and url changed to that of default virtual host

So i tried with PunyCode:
server_name www.xn--nicolzanetti-rhb.com xn--nicolzanetti-rhb.com www.nicolòzanetti.com nicolòzanetti.com;
https://www.nicolòzanetti.com -> Works!
https://nicolòzanetti.com -> Works!
http://www.nicolòzanetti.com -> Default virtual host and url changed to that of default virtual host
http://nicolòzanetti.com -> Default virtual host and url changed to that of default virtual host

I even tried to use regex with ~^www\.nicolòzanetti.com$ and ~^www\.nicol.zanetti\.com$, but it failed again.
I should use the encode function? If yes where can I find some examples please?



Edited 1 time(s). Last edit at 03/13/2014 07:17AM by Dzhalagash.
Re: URL special characters, punycode and http
March 14, 2014 09:35AM
I found out that this same configuration tested in Firefox has a different output when tested in Chrome.
Dzhalagash Wrote:
-------------------------------------------------------
> server_name www.xn--nicolzanetti-rhb.com xn--nicolzanetti-rhb.com
> www.nicolòzanetti.com nicolòzanetti.com;
> https://www.nicolòzanetti.com -> Works!
> https://nicolòzanetti.com -> Works!
> http://www.nicolòzanetti.com -> Default virtual host and url changed
> to that of default virtual host
> http://nicolòzanetti.com -> Default virtual host and url changed to
> that of default virtual host

https://www.nicolòzanetti.com -> Works!
https://nicolòzanetti.com -> Works!
http://www.nicolòzanetti.com -> Works!
http://nicolòzanetti.com -> Works!
That's weird, maybe Chrome encodes the url differently? What may be a possible explanation? Any way to force Firefox to encode the url the same way Chrome does from the server side perspective?
Re: URL special characters, punycode and http
March 14, 2014 09:58AM
You might be better of using wildcards to capture whatever a browser thinks it needs to send, http://nginx.org/en/docs/http/server_names.html use logging to find out where to wildcard.
Re: URL special characters, punycode and http
March 21, 2014 08:14PM
It was a problem of Firefox DNS cache.
Althougth it makes little sense for me thinking about it now, it was the correct solution to try and reset firefox dns.
Once DNS (that were set to last 30 days, or 2592000") were flushed, Firefox correctly redirected me to the right website instead of the default.
There wasn't anything helpful in my access_logs or error_logs sadly, and wildcard weren't much helpful as well, but thanks anyway for the help itpp2012.
Punycode (xn--nicolzanetti-rhb) were the answere, once the DNS were flushed at least.
Therefore my correct configuration is:
server_name
www.xn--nicolzanetti-rhb.com xn--nicolzanetti-rhb.com
www.nicolòzanetti.com nicolòzanetti.com
www.nicolozanetti.com nicolozanetti.com;
If works perfectly in IE, FF and Chrome, in Opera the url doesn't get translated but it works, I see xn--nicolzanetti-rhb.com in the url bar instead of nicolòzanetti.com, but that's not a big concern.
I'll have now to find a way to configure the email as well, since as with opera I see the punycode url, but that's on me.
I am writing this last comment in hope that it will be useful to somebody else someday.



Edited 1 time(s). Last edit at 03/21/2014 08:16PM by Dzhalagash.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 152
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready