Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling JBoss AS 7 Directory Listings

Tags:

jboss7.x

I have the following directory structure deployed to JBoss AS 7.1.1.Final (under standalone/deployments):

doc.war
    -> module1
        -> index.html
    -> module2
        -> index.html

As you can see, there's no index.html under doc.war. When I browse to localhost:8080/doc/module1/, the correct index.html is displayed, but when I browse to localhost:8080/doc/, JBoss shows an error message (404 - The requested resource is not available).

I think this is related to the fact that directory listings are turned off by default in JBoss AS 7. How can I enable directory listings, either globally or more specifically for this one application?

Edit

Based on Mukul Goel's answer, I ran the CLI command to add the static-resources feature, restarted the server and retried the request, but it didn't work.

Here's the relevant snippet from the standalone.xml file. Please note that I have the native connector enabled.

<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="true">
    <configuration>
        <static-resources listings="true"/>
    </configuration>
    <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
    <connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https"/>
    <virtual-server name="default-host" enable-welcome-root="true">
        <alias name="localhost"/>
        <alias name="example.com"/>
    </virtual-server>
</subsystem>

Here's the error message that JBoss is showing:

JBoss Error Message

Update

So the conclusion to this seems to be that there is an issue with the official JBoss 7.1.1.Final (http://www.jboss.org/jbossas/downloads) download. I didn't manage to get Directory Listings working with this version. Trying a later version (from the JBoss CI server at https://ci.jboss.org/jenkins/job/JBoss-AS-7.x-latest/), I was able to see the directory listings after applying the config change that Mukul Goel had suggested below.

A potential source of this issue could be the version of JBossWeb that is used in JBoss. The official 7.1.1.Final bundles JBossWeb 7.0.13. Mukul (see below) was able to get it working running a version of JBoss that bundles JBossWeb 7.0.16.

I'm accepting Mukul Goel's answer as solving this issue, but be aware that it will probably not work with the official 7.1.1.Final download.

like image 990
nwinkler Avatar asked Feb 19 '23 22:02

nwinkler


1 Answers

Yes you are right, directory listings are by default disabled (a security measure)

To enable directory listing in JBOSS

Try running the following CLI command to enable diectory listing:

In Domain Mode

/profile=full/subsystem=web/configuration=static-resources/:write-attribute(name=listings,value=true)

.

In Standalone Mode

/subsystem=web/configuration=static-resources/:write-attribute(name=listings,value=true)

It will generate following kind of configuration :

        <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">

            <configuration>
                <static-resources listings="true"/>
            </configuration>


            <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
            <virtual-server name="default-host" enable-welcome-root="true">
                <alias name="localhost"/>
                <alias name="example.com"/>
            </virtual-server>
        </subsystem>

UPDATE: Tried it myself as the user is facing problems

RAN CLI command for the standaloneMode

This was generated, note that the native is disabled also there is no HTTPS connector generated for me (Don`t know why it is showing enabled for you? are you using openSSL somewhere? )

relevant code from standalonex.ml

I created a sample webprojet(a client side project) with two htmls ,published it to jboss and hit url

http://localhost:8080/sample/

and this is the screenshot of directory listing

Directory listing screenshot

The command worked it for me, So that does turns on Directory listing on JBOSS AS7.1.1 Final(I am also using the same version) So the question comes down to rest of your server configuration, your application structure, technologies you are using, springs etc and also if you are using some ssl library.

UPDATE 2 Suggested a fresh download and reconfigure environment and see nwinkler was still facing issues even with a fresh distribution (JbossWeb 7.0.13) So suggested to take nightly builds from

ci.jboss.org/jenkins/job/JBoss-AS-7.x-latest

Just go to the link and download whats under last successful artifact

And the problem was resolved. Looks like some bug with jbossWeb 7.0.13

Do go through the comments, the discussion might be helpful

like image 176
4 revs Avatar answered Apr 06 '23 04:04

4 revs