4 Replies Latest reply on Dec 23, 2013 7:02 AM by rhusar

    Wildfly with nginx serving static resources

    mpapo

      Hi all,

       

      Is there a way to integrate Wildfly and nginx ?

      I would like to serve static resources with nginx. Since all static resources are stored in a temp directory named with random characters in Wildfly, it's hard to configure it with nginx.

      Is there a way to do that ?

       

      Thanks in advance.

      Michaël

        • 1. Re: Wildfly with nginx serving static resources
          rhusar

          Is there a way to integrate Wildfly and nginx ?

          I have never tried, but it should work. WildFly exposes both AJP and HTTP connectors.

           

          I would like to serve static resources with nginx. Since all static resources are stored in a temp directory named with random characters in Wildfly, it's hard to configure it with nginx.

          Sounds like an antipattern. Static should be static and should be served directly from the balancer, withouth having to rely on the app server. E.g. page like 503 when the AS goes down (restart/crash) you would serve a nice static error page -- and you cannot serve that from the AS.

           

          Is there a way to do that ?

          Serve static from a different location even though it adds one more step for the deployment.

          • 2. Re: Wildfly with nginx serving static resources
            mpapo

            Hum well, it seems that I'm not very clear in my request.

            I have a Java web project with all static resources (css, js and images files) in webapps/static folder in the war.

            I would like to configure Nginx in front of Wildfly to serve directly these static resources.

            • 3. Re: Wildfly with nginx serving static resources
              ctomc

              Hey,

               

              you can configure nginx to specially handle certain paths / patterns like images / css / javascript.

               

              I usually have all that static content under some common path like /static/ or /_common/

              and then configure nginx to serve it from disk, but it it is not there you configure error handler 404 to actualy be caching proxy handler.

              that fetches backend and when it gets result, saves it to some location on disk (same from which you server this location)

               

              this way you get simple static serving from nginx but in case that content does not exist yet it will go fetch it to backend server (wildfly)

               

              --

              tomaz

              1 of 1 people found this helpful
              • 4. Re: Wildfly with nginx serving static resources
                rhusar

                you can configure nginx to specially handle certain paths / patterns like images / css / javascript.

                 

                I usually have all that static content under some common path like /static/ or /_common/

                and then configure nginx to serve it from disk, but it it is not there you configure error handler 404 to actualy be caching proxy handler.

                that fetches backend and when it gets result, saves it to some location on disk (same from which you server this location)

                 

                this way you get simple static serving from nginx but in case that content does not exist yet it will go fetch it to backend server (wildfly)

                Exactly. Can you share a configuration snippet?