JBoss as an http server?

I am trying to write webapp where the server side provides only json / REST services, and gui is written to html5, spine, puppet, etc. using async XHR. Html, js, css etc. They are static and cached (when deployed to production).

I need to deploy this to JBoss EAP6 (in general, equivalent to AS7 for this problem). During development, I would like to be able to edit my javascript and html templates and instantly view the results in a browser. In production, I need my static content (front-end) to explode and not be deployed in any kind of Java EE structure (so there is no war or ear (or sar)).

So basically, I need to deploy wars in jboss, as usual, and I also need jboss to work as an http server for the static part of the application.

I played with the idea of ​​copying my content to the welcome-content directory in the root of EAP6. Although this works seamlessly with content, I cannot work with this structure for development because I cannot live with the overhead of time copying my changes to another directory. I also tried using the symlink from welcome-content for my static content in dev environment, but this does not work in this version of jboss.

Edit: I have answers that tell me how to get around the problem, but I really don't get hung up on the workaround - it's easy. I am really looking specifically at how to configure jboss to serve static content.

TIA.

+9
jboss cdn
source share
3 answers

You can simply deploy the static html / css / js as usual and use the tool to make changes to the DOM for you in real time. I do this with GruntJS using grunt-contrib-watch and it works very well.

0
source

Update
TL; DR I assume that the original problem has long been resolved more than 5 years after its inception. If someone really insists on using JBoss as a static file web server, then the solution mentioned in the question is the SOLUTION - using the welcome-content directory. To use EAP6, you must have an active paid subscription from RedHat, and its knowledge base gives the same answer .
Since this is no longer 2013, copying a few static files really shouldn't be a problem, and most IDEs can handle this pretty well (just copying files that have changed, etc.).
For everyone else who comes here from Google, IMHO is more profitable to indicate the right tools for work and separate deployment of the backend and external interface (by the way, Nginx was available long before 2013, and Apache has been here, well, ever since: )).

Although your static web resources can be hosted through JBoss, this is a pretty inefficient use of the Java web server. Since your Frontend is completely separate from your Java backend, why not deploy it on a dedicated web server - for example, Nginx or Apache, which will be much more efficient and suitable for serving static content (or dedicated Wildfly w / Undertow, if you must )

You do not specify if you have only one JBoss instance or a more complex deployment, but one common scenario for a use case like yours is as follows:

  [Nginx server:80] <--> [JBoss server:8080] - location / { |- your-backend.war root /path/to/frontend (web context /myapp/api) } - location /api { proxy_pass http://backend } 

For more information, go to the Nginx documentation .

Benefits of using a dedicated web server:

  • You can use it as a load balancer at the same time, just add more instances of Jboss, update the initial configuration and get a scalable backend, yes
  • Deploying your external interface is just a copy of static files to the appropriate folder - there is no need to restart, you can configure the paths according to the structure of your folder.
  • Nginx (or well-tuned Apache) can easily handle extreme loads, it uses an event mechanism instead of threads, + you can play with caching strategies, etc.
  • You free your Java web server from the overhead of maintaining static web resources and configure it to do what is best for the Java web service server
  • You can deploy several web interfaces or several projects with different host names so that you can host dev and test versions of your application on the same physical server and link them to check https://dev.myapp.com and https: // test .myapp.com
  • You can use the web server to offload SSl - again, freeing the JBoss application server from the burden of SSL processing.
-one
source

Update for JBoss EAP 7.x


In addition to the previous answers, JBoss EAP 7.x emphasized that it emphasizes the https / 2 server. Therefore, it has its own properties and has the following basic properties:

 <subsystem xmlns="urn:jboss:domain:undertow:1.0"> <buffer-caches> <buffer-cache name="default" buffer-size="1024" buffers-per-region="1024" max-regions="10"/> </buffer-caches> <server name="default-server"> <http-listener name="default" socket-binding="http" /> <host name="default-host" alias="localhost"> <location name="/" handler="welcome-content" /> </host> </server> <servlet-container name="default" default-buffer-cache="default" stack-trace-on-error="local-only" > <jsp-config/> <persistent-sessions/> </servlet-container> <handlers> <file name="welcome-content" path="${jboss.home.dir}/welcome-content" directory-listing="true"/> </handlers> </subsystem> 

Link: Undertow.io

Cli team

Therefore, you can change the properties using the CLI command and subsystem = undertow:

 /subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=url-charset,value="utf-8") 

Static Content in Undertow

This other question describes a similar situation, and the official documentation describes a file handler for serving static files.

Cli command to create a file handler:

 /subsystem=undertow/configuration=handler/file=new-file-handler:add(path="${jboss.home.dir}/welcome-content") 
-one
source

All Articles