4 Replies Latest reply on Feb 16, 2014 10:58 PM by Madhu Shinde

    JBOSS AS 7.1.1 URL Redirect

    Madhu Shinde Newbie

      @Hi ,

       

      I need to redirect URL, if I enter www.hello.com to my application.

       

      Criteria.

      1.I need to direct from port 80 to 8080.

      2.In my URL I need to hide root context name.

           this can be achieved by using "/" in jboss-web.xml but I need to have context root i.e name of the project.

       

      3.All this need to be handled in StandAlone.xml file.

       

      Please kindly provide me solution.

       

       

      Thank you.

        • 1. Re: JBOSS AS 7.1.1 URL Redirect
          Filippe Spolti Novice

          Hi,

           

          1.I need to direct from port 80 to 8080

               Maybe you can add a iptables rule to redirect, like this:

               # iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

           

           

          2.In my URL I need to hide root context name

             I need to redirect URL, if I enter www.hello.com to my application.

             

          OK, you must do 2 things, configure the application context root and configure a virtual host, configure the jboss vhost then add you domain in your DNS server, or locally for tests.

           

               First: Configure the application context root and configure a virtual host

               Your jboss-web.xml must be like that:

           

               <?xml version="1.0" encoding="UTF-8" ?>

           

              <jboss-web>

                         <context-root>/</context-root>

                         <virtual-host>www.hello.com</virtual-host>

               </jboss-web>


               Second:

               In your standalone|domain.xml, in the  urn:jboss:domain:undertow:1.0 subsystem, between server tags, add this conf:


                    <host name="V_HOST_NAME" alias="www.hello.com" default-web-module="APP_NAME"/>

               Typically the default-web-name is the war name whithout suffix, or you are using maven you mus use <artifactId> name.



               Third: Configure your DNS.

           

                  

          Rgz

          • 2. Re: JBOSS AS 7.1.1 URL Redirect
            Madhu Shinde Newbie

            Hello,

             

            Thanks a ton . It helped me.

             

            Regards

            • 3. Re: JBOSS AS 7.1.1 URL Redirect
              Vijay Bhaskar Chintalapati Newbie

              If you are just tinkering with your personal system at home or work, the above approach might work. I probably will be suggesting something that you didn't ask for but I will continue ...

               

              The usual and often best practice is to have a Web Server like Apache or JBoss EWS in front of the JBoss Application Server as it also doubles as Load Balancer if you ever prefer to use it that way.

              • Once installed you can add a VirtualHost entry into the httpd.conf file, just as shown in the post here.
              • As a final tweak you have to ensure that www.example.com is pointed to the machine where the app is installed/running, so you have to modify the DNS entries to do the required mapping.

               

              Also, "Accept" the replies providing your desired solution. This will give points to the people contributing to solutions in the community.

              • 4. Re: JBOSS AS 7.1.1 URL Redirect
                Madhu Shinde Newbie

                Hello,

                 

                Thank you for the reply .I would try out this solution too.Will post the update.

                 

                Regards