Am 24.08.20 um 16:41 schrieb Aryeh Friedman: > On Mon, Aug 24, 2020 at 4:27 AM Mark Thomas <ma...@apache.org> wrote: > >> On 23/08/2020 22:05, Aryeh Friedman wrote: >>> In order to allow my developers to quickly access any temporarily >> produced >>> html files created/stored outside of webapps (such as those created by >> the >>> jacoco test coverage tool) I want to allow read only access to the root >>> directory of the development server (firewalled and all access outside of >>> the LAN is disabled) via tomcat. I can get it to do any directory >>> *EXCEPT* / as the docBase but a docBase of "/" returns an empty dir >> listing >>> (which is obviously wrong): >>> >>> In config/web.xml: >>> <servlet> >>> <servlet-name>default</servlet-name> >>> >>> >> <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class> >>> <init-param> >>> <param-name>debug</param-name> >>> <param-value>0</param-value> >>> </init-param> >>> <init-param> >>> <param-name>listings</param-name> >>> <param-value>true</param-value> >>> </init-param> >>> <load-on-startup>1</load-on-startup> >>> </servlet> >> That should be sufficient to enable directory listings for all web >> applications. >> >>> In server.xml (this works): >>> <Host name="localhost" appBase="webapps" >>> unpackWARs="true" autoDeploy="true"> >>> >>> <!-- SingleSignOn valve, share authentication between web >>> applications >>> Documentation at: /docs/config/valve.html --> >>> <!-- >>> <Valve >> className="org.apache.catalina.authenticator.SingleSignOn" /> >>> --> >>> >>> <!-- Access log processes all example. >>> Documentation at: /docs/config/valve.html >>> Note: The pattern used is equivalent to using >> pattern="common" >>> --> >>> <Valve className="org.apache.catalina.valves.AccessLogValve" >>> directory="logs" >>> prefix="localhost_access_log" suffix=".txt" >>> pattern="%h %l %u %t "%r" %s %b" /> >>> <Context docBase="/fakeRoot" path="/files"> >>> </Context> >> I'd do this with a ROOT.xml file in >> $CATALINA_BASE/conf/Catalina/localhost but the above should work. >> >>> But this does not work: >>> <Context docBase="/" path="/files"> >> The docBase is not correct (it should be "") but Tomcat probably will >> let you get away with that. >> >> > Tried and it gives me /usr/local/apache-tomcat-9.0/webapps as the effective > dir. This is *NOT* what I meant by the root dir I meant the one that is > the highest point in the file system hierarchy (i.e. the one you get when > at a shell prompt when you type "cd /") [this is for a Unix machine of > course since Windows has no concept of such a directory/folder]
It seems, that Tomcat will do a bit of cleanup on the paths you specify in docBase. If I read it correctly, ContextConfig#fixDocBase will convert the base you give to a canonical representation and remove the leading slash. Therefore, if you specify docBase="/" (to indicate the mount point "/" aka root of the filesystem), Tomcat will change it to "", which then (and this is guessing) could lead to a state, Tomcat doesn't know where to find any files. I believe, there is no easy (safe/sane) way to get Tomcat (that is the DefaultServlet) serve the OS-root as you want to have it. There are probably other things you can do, to achieve your goals. Use a real filemanager app inside of Tomcat, or use another lightweight http server (if you really want to use http for this). Python3 has a built-in module http.server, which could be used to do this with a one-liner in shell. But, as others already said: Be careful! Felix > > >> I tested this locally and it works as expected. >> >> Maybe a file permissions issue? >> >> Mark >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org >> For additional commands, e-mail: users-h...@tomcat.apache.org >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org