...
- http://777.888.888.111:8080/
- http://www.other.com:8080/
- http://www.other.net:8080/
- http://www.other.org:8080/
Configuring virtual hosts with non-ascii characters
International domain names are names containing non-ascii characters. For example "http://www.bücher.com". The DNS internally remains based on ascii, so these kinds of names are translated via an encoding called punycode into an ascii representation. Modern browsers will detect these non-ascii characters in URLs and automatically apply the punycode encoding. For example, typing this url into a browser:
| No Format |
|---|
http://www.åäö.com:8080/test/ |
is translated to the following url:
| No Format |
|---|
http://www.xn--4cab6c.com:8080/test/ |
For using internationalized domain names with jetty virtual hosts, you need to supply the punycoded form of the name in your context xml file (and of course you will need to supply it to your DNS setup).
Here's an example. Say I'm running a webapp on port 8080 at context /test, and I want to configure a virtual host for "www.åäö.com". I configure its ascii equivalent in the context xml file for the context:
| Code Block | ||
|---|---|---|
| ||
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/</Set>
<Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/test.war</Set>
<Set name="virtualHosts">
<Array type="String">
<Item>www.xn--4cab6c.com</Item>
</Array>
</Set>
</Configure>
|
After starting jetty, I will be able to enter the url "http://www.åäö.com:8080/test/" in my browser and reach my webapp.
Note that if I don't have any webapps deployed at /, hitting the url "http://www.åäö.com:8080" will hit jetty's default handler, which serves back a 404 page listing the available contexts:
| Panel |
|---|
Error 404 - Not Found No context on this server matched or handled this request. Contexts known to this server are:
|
You'll notice that the link already has the punycode transformed domain name in it.