2 Replies Latest reply on Aug 16, 2009 11:55 AM by andrew inden

    Problem changing default ports

    andrew inden Newbie

      I am using jboss-5.0.0.GA.

      I have changed values of the default ports from 8080 to 80 and 8443 to 443 in the server.xml file located in the %JBOSS_HOME%\server\default\deploy\jbossweb.sar directory


       <Connector protocol="HTTP/1.1" port="80" address="${jboss.bind.address}"
       connectionTimeout="20000" redirectPort="443" />
      
       <Connector protocol="HTTP/1.1" SSLEnabled="true"
       port="443" address="${jboss.bind.address}"
       scheme="https" secure="true" clientAuth="false"
       keystoreFile="${jboss.server.home.dir}/conf/server.keystore"
       keystorePass="serverpass" sslProtocol="TLS" />
      


      I have place my server.keystore file in the %JBOSS_HOME%\server\default\conf directory.

      When I deploy the ear and navigate to restricted servlet (http://localhost/myapp/myrestrictedservlet) I get "Firefox can't establish a connection to the server at localhost:8443" or "Internet Explorer cannot display the webpage".

      If I navigate to restricted servlet and specify a port (https://localhost:443/myapp/myrestrictedservlet) I am presented with the j_security_check form. When I submit correct credentials I get "Hello World".

      It seams as though the redirectPort attribute of Connector in the server.xml is being overridden or not picked up.


      The port attribute was picked up because I can navigate to http://localhost/jmx-console/.


      Thank you for any help you can provide...



      File Organization:
      
      myapp.ear
      ----META-INF
      --------application.xml
      --------MANIFEST.MF
      ----dynamic-login.jar
      --------dynamic-login-config.xml
      --------META-INF
      ------------MANIFEST.MF
      ----myapp.war
      --------restricted
      ------------bad-login.html
      ------------login.html
      --------META-INF
      ------------MANIFEST.MF
      --------WEB-INF
      ------------web.xml
      ------------jboss-web.xml
      --------classes (etc...)
      






      -----------------------------------------------------------------------------------------
      server.xml
      -----------------------------------------------------------------------------------------
      
      <Server>
      
       <!-- Optional listener which ensures correct init and shutdown of APR,
       and provides information if it is not installed -->
       <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
       <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
       <Listener className="org.apache.catalina.core.JasperListener" />
      
       <Service name="jboss.web">
      
       <!-- A HTTP/1.1 Connector on port 8080 -->
       <Connector protocol="HTTP/1.1" port="80" address="${jboss.bind.address}"
       connectionTimeout="20000" redirectPort="443" />
      
      
       <Connector protocol="AJP/1.3" port="8009" address="${jboss.bind.address}"
       redirectPort="443" />
      
       <Connector protocol="HTTP/1.1" SSLEnabled="true"
       port="443" address="${jboss.bind.address}"
       scheme="https" secure="true" clientAuth="false"
       keystoreFile="${jboss.server.home.dir}/conf/server.keystore"
       keystorePass="serverpass" sslProtocol="TLS" />
      
      
      
       <Engine name="jboss.web" defaultHost="localhost">
      
       <Realm className="org.jboss.web.tomcat.security.JBossWebRealm"
       certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
       allRolesMode="authOnly"
       />
      
       <Host name="localhost">
      
       <Valve className="org.apache.catalina.valves.RequestDumperValve" />
      
       <Valve className="org.apache.catalina.valves.AccessLogValve"
       prefix="localhost_access_log." suffix=".log"
       pattern="common" directory="${jboss.server.log.dir}"
       resolveHosts="false" />
      
       <Valve className="org.jboss.web.tomcat.service.jca.CachedConnectionValve"
       cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager"
       transactionManagerObjectName="jboss:service=TransactionManager" />
      
       </Host>
      
       </Engine>
      
       </Service>
      
      </Server>
      






      -----------------------------------------------------------------------------------------
      dynamicloginconfig-service.xml
      -----------------------------------------------------------------------------------------
      
      
      <?xml version="1.0" encoding="UTF-8"?>
      
      <server>
      
       <mbean code="org.jboss.security.auth.login.DynamicLoginConfig" name="jboss:service=DynamicLoginConfig">
       <attribute name="AuthConfig">dynamic-login-config.xml</attribute>
      
       <depends optional-attribute-name="LoginConfigService">jboss.security:service=XMLLoginConfig</depends>
      
       <depends optional-attribute-name="SecurityManagerService">jboss.security:service=JaasSecurityManager</depends>
       </mbean>
      </server>
      
      


      -----------------------------------------------------------------------------------------
      application.xml
      -----------------------------------------------------------------------------------------

      
      <?xml version="1.0" encoding="UTF-8"?>
      
      <application>
       <display-name>My App</display-name>
       <module>
       <web>
       <web-uri>myapp.war</web-uri>
       <context-root>/myapp</context-root>
       </web>
       </module>
       <module>
       <ejb>dynamic-login.jar</ejb>
       </module>
      </application>
      
      
      






      -----------------------------------------------------------------------------------------
      security-mysql-ds.xml
      -----------------------------------------------------------------------------------------
      
      
      <?xml version="1.0" encoding="UTF-8"?>
      
      <datasources>
       <local-tx-datasource>
       <jndi-name>jdbc/myAppDS</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/myappdb</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>myuser</user-name>
       <password>mypassword</password>
       <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
       <min-pool-size>5</min-pool-size>
       <max-pool-size>20</max-pool-size>
       <idle-timeout-minutes>15</idle-timeout-minutes>
       <metadata>
       <type-mapping>mySQL</type-mapping>
       </metadata>
       </local-tx-datasource>
      </datasources>
      







      -----------------------------------------------------------------------------------------
      dynamic-login-config.xml
      -----------------------------------------------------------------------------------------
      
      <?xml version="1.0" encoding="UTF-8"?>
      
      <!DOCTYPE policy PUBLIC
       "-//JBoss//DTD JBOSS Security Config 3.0//EN"
       "http://www.jboss.org/j2ee/dtd/security_config.dtd">
      
      <policy>
      
       <application-policy name="my-security-domain">
       <authentication>
       <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule"
       flag="required">
       <module-option name="unauthenticatedIdentity">guest</module-option>
       <module-option name="dsJndiName">java:/jdbc/myAppDS</module-option>
       <module-option name="principalsQuery">SELECT vpassword FROM VUser WHERE vname=?</module-option>
       <module-option name="rolesQuery">SELECT vrole, 'Roles' FROM VRole WHERE vname=?</module-option>
       </login-module>
       </authentication>
       </application-policy>
      
      </policy>
      
      





      -----------------------------------------------------------------------------------------
      web.xml
      -----------------------------------------------------------------------------------------
      
      <?xml version="1.0" encoding="UTF-8"?>
      
      <web-app version="2.5"
       xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
      
       <servlet>
       <servlet-name>MyRestrictedServlet</servlet-name>
       <servlet-class>com.myapp.MyRestrictedServlet</servlet-class>
       </servlet>
      
       <servlet-mapping>
       <servlet-name>MyRestrictedServlet</servlet-name>
       <url-pattern>/myrestrictedservlet</url-pattern>
       </servlet-mapping>
      
       <security-constraint>
       <web-resource-collection>
       <web-resource-name>HtmlAdaptor</web-resource-name>
       <url-pattern>/sayhello</url-pattern>
       <http-method>GET</http-method>
       <http-method>POST</http-method>
       </web-resource-collection>
       <auth-constraint>
       <role-name>admin</role-name>
       </auth-constraint>
       <user-data-constraint>
       <transport-guarantee>CONFIDENTIAL</transport-guarantee>
       </user-data-constraint>
       </security-constraint>
      
       <login-config>
       <auth-method>FORM</auth-method>
       <form-login-config>
       <form-login-page>/restricted/login.html</form-login-page>
       <form-error-page>/restricted/bad-login.html</form-error-page>
       </form-login-config>
       </login-config>
      
       <security-role>
       <role-name>admin</role-name>
       </security-role>
      
      </web-app>
      
      
      


      -----------------------------------------------------------------------------------------
      jboss-web.xml
      -----------------------------------------------------------------------------------------
      
      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-web>
       <security-domain>java:/jaas/my-security-domain</security-domain>
      </jboss-web>