-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Symlinks cause 404 with DefaultServlet when its "resourceBase" is different from ContextHandler's #8259
Comments
addressing Jetty bug with DefaultServlet: jetty/jetty.project#8259
addressing Jetty bug with DefaultServlet: jetty/jetty.project#8259
If you have a ContextHandler (or WebAppContext) resourceBase set, then the actual DefaultServlet (on url-pattern If you want another DefaultServlet, not on the usual servlet default requirement, then you can specify extra DefaultServlet's to then have a resourceBase declared for each. There's examples of this at https://github.com/jetty-project/embedded-jetty-cookbook/blob/jetty-10.0.x/src/main/java/org/eclipse/jetty/cookbook/DefaultServletMultipleBases.java |
Yep, this is what I do (my DefaultServlet is mapped to "/asset/*", ContextHandler resource base is not set). But due to symlinks in the servlet's resource base, it stopped working after upgrading from Jetty 9 to 10. That's the problem that I described above. |
Please set |
That is correct, If you have multiple Resource bases, then the Alias Checking built into Jetty is not able to satisfy your ruleset. You will need to implement your own If you choose to use a single Resource Base, but with multiple entries declared, use the |
I should be able to provide these details next week.
I theory, yes. E.g. a Bootique app may have 2 DefaultServlets, one serving files from the classpath (i.e. packaged in the app jar), and another - from a folder on the filesystem (some examples given here).
So that explains why it worked in Jetty 9 :)
Let me check it out. |
Here is the startup dump sanitized from the organization specific data. |
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
@andrus In PR #8315 I have added a new constructor You can see this test as an example This will be released with a 10.0.12/11.0.12 version. |
Looking forward the 10.0.12/11.0.12 releases. Thanks! |
Jetty version(s)
10.0.11 ... This worked on 9.x
Java version/vendor
(use: java -version)
openjdk version "11.0.14.1" 2022-02-08
OS type/version
Mac OS 12.4
Description
The problem:
DefaultServlet
can't serve files located in symlinked directories if its resource base is different from its parentContextHandler
.I am running Jetty with Bootique Framework.
ContextHandler
has no "resourceBase" set. There is aDefaultServlet
that has "resourceBase" set to say/opt/p/c
. If/opt/p/c
are all regular folders, I can serve static files from this path via theDefaultServlet
. Ifc
is a symlink to a folder outside ofp
, I am getting a 404. Debugging shows that the culprit is alias checking bySymlinkAllowedResourceAliasChecker
.Workaround 1: setting
ContextHandler.resourceBase
to/opt/p/c
makes things work again. This isn't always applicable, as I may have multiple DefaultServlets pointing to different folders on the filesystem.Workaround 2: Using deprecated
AllowSymLinkAliasChecker
:Desired behavior: in
SymlinkAllowedResourceAliasChecker
make alias checking to work relative to the DefaultServlet base.The text was updated successfully, but these errors were encountered: