Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Customizing 404 response for virtual hosts

John,

Your jetty.xml you posted does not look correctly configured. You should have a HandlerList containing a ContextHandlerCollection (which contains your webapp with its virtual host setup) and a DefaultHandler. If you webapp does not answer the request because the virtual hosts don't match, the request will fall through the HandlerList to the DefaultHandler.  Now, the DefaultHandler is not particularly customizable, however you could easily write your own handler to pump out the kind of error page you want.

Jan

On 16 August 2015 at 20:23, John English <john.foreign@xxxxxxxxx> wrote:
On 06/08/2015 13:25, John English wrote:
It would appear from my experiments that when there are multiple
"setHandler" blocks defining webapps all mapped to "/", the last one
wins if the virtual host lists are not disjoint. If I have one accepting
127.0.0.1 (A) and another without a VH list (B), specifying A then B
means that B always responds. If I reverse the order (B then A), A
accepts 127.0.0.1 correctly, but generates a default 404 page for
127.0.0.2 rather than invoking B.

Since no-one has been able to tell me how to solve my problem, I've eventually stopped using virtual hosts completely due to the apparent inability of Jetty to let you customise the 404 response to an invalid hostname, and instead I have added a filter to the servlet chain that inspects the hostname before honoring the request, and then if it's not in the aproved hostname list I can process it however I like. Clunky, but it has the advantage of actually working.

Maybe it's different in Jetty 9 (I plan to upgrade soon, promise) but once again the docs don't cover this particular problem so I'm not that optimistic it'll be any easier.

--
John English
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top