8 Replies Latest reply on Jan 11, 2016 5:13 AM by sreekanth.munarai

    Redirection of Port in JBoss 5.1.0

    sreekanth.munarai

      Hi All,

       

      We have enabled SSL on jboss and able to access application thru https://localhost:8443/Myapp

       

      Client requirement is when the user fires URL https://localhost:8443/Myapp it should be redirected to https://localhost:7443/Myapp

       

      User should be redirected to URL with 7443 from 8443

      Have spent hours on googling but no luck:(

      Please can anyone help me how to get the above things done. its on higher priority for us. Thanks in advance. Sreekanth

        • 1. Re: Redirection of Port in JBoss 5.1.0
          jaysensharma

          Configure your JBoss to listen on HTTPs port 7443 and then try port forwarding should be a simple option:

           

            /sbin/iptables -t nat -A PREROUTING -p tcp --dport 8443 -d 192.168.x.x -j DNAT --to 192.168.x.x:7443
          

           

          Here "192.168.x.x" will be your hostname.

          See: https://developer.jboss.org/wiki/UsingPortForwardingWithJBoss

           

          Regards

          Jay SenSharma

          • 2. Re: Redirection of Port in JBoss 5.1.0
            sreekanth.munarai

            Hi Jay,

             

            Is this something IT/networking level or something we can change in jboss configuration??

            • 3. Re: Redirection of Port in JBoss 5.1.0
              sreekanth.munarai

              and we are on windows OS!!

              • 4. Re: Redirection of Port in JBoss 5.1.0
                jaysensharma

                Try this:

                 

                1.   Create a file as following "$PROFILE/conf/jboss.web/localhost/rewrite.properties"

                 

                RewriteCond %{SERVER_PORT} ^8443$
                RewriteRule ^(.*)$ https://localhost:7443/$1 [R]
                

                 

                2.  Add the following entry in the "$PROFILE/deploy/jbossweb.sar/server.xml"

                 

                      <!-- SSL/TLS Connector configuration using the admin devl guide keystore
                      <Connector protocol="HTTP/1.1" SSLEnabled="true"
                           port="8443" address="${jboss.bind.address}"
                           scheme="https" secure="true" clientAuth="false"
                           keystoreFile="${jboss.server.home.dir}/conf/chap8.keystore"
                           keystorePass="rmi+ssl" sslProtocol = "TLS" />
                      -->
                
                      <!-- SSL/TLS Connector configuration using the admin devl guide keystore-->
                      <Connector protocol="HTTP/1.1" SSLEnabled="true"
                           port="7443" address="${jboss.bind.address}"
                           scheme="https" secure="true" clientAuth="false"
                           keystoreFile="${jboss.server.home.dir}/conf/jbossweb.keystore"
                           keystorePass="JbossPassword" sslProtocol = "TLS" />
                

                 

                3. Now in the same "$PROFILE/deploy/jbossweb.sar/server.xml" enable the following Valve inside the <Host> </Host> tags:

                 

                            <Valve className="org.jboss.web.rewrite.RewriteValve" />
                

                 

                4. Restart JBoss

                 

                5. Try accessing the URL:                     https://localhost:8443/MyApp

                     You will find that it is redirected to :  https://localhost:7443//MyApp

                 

                 

                Regards

                Jay SenSharma

                • 5. Re: Redirection of Port in JBoss 5.1.0
                  sreekanth.munarai

                  do we need to create one more certificate for the 2nd SSL tags??and I dont see any folder jboss.web. Please advise

                  • 6. Re: Redirection of Port in JBoss 5.1.0
                    jaysensharma

                    do we need to create one more certificate for the 2nd SSL tags??

                    >>>   No Just create another HTTPS connector to listen to 7443 (or 8443) So that at least the port is opened to listen to https.    You can use the same certificate for both the ports.

                     

                    I don't see any folder jboss.web

                    >>> You will need to create it.   "$PROFILE/conf/jboss.web/localhost/rewrite.properties"

                        

                    See:  JBoss Web - Overview    to know more about how the Valve "org.jboss.web.rewrite.RewriteValve" works.

                    The valve will then use a rewrite.properties file containing the rewrite directives, located according to the container it is assocaited to:

                    • If associated with an engine, it should be placed in a folder named [engine_name] placed either in the classloader, or in the conf folder of the current JBoss profile
                    • If associated with a host, it should be placed in a folder named [engine_name]/[host_name] placed either in the classloader, or in the conf folder of the current JBoss profile
                    • If associated with a context, it should be placed in the WEB-INF folder of the web application

                     

                    Regards

                    Jay SenSharma

                    • 7. Re: Redirection of Port in JBoss 5.1.0
                      sreekanth.munarai

                      WoW!! Jay, you are magician!!!

                      Above things worked like charm!!:D

                      Thanks a lot!! cheers!!!

                      • 8. Re: Redirection of Port in JBoss 5.1.0
                        sreekanth.munarai

                        Jay, one more thing need to be asked:

                        Do we have to follow same steps for JBoss7.1.0 and JBoss7.1.1 as-well to achieve redirection ports issue?Thanks