2012-03-02 123 views
9

我正嘗試將非SSL端口8080上的流量重定向到SSL端口8443(在Jboss 4.2.3.GA版本上),但它不起作用。當我在此端口上訪問我的web應用程序時,它停留在該端口上並顯示頁面。這是我在server.xml文件從非ssl端口8080重定向到ssl端口8443

<Connector port="8080" address="${jboss.bind.address}"  
    maxThreads="250" maxHttpHeaderSize="8192" 
    emptySessionPath="true" protocol="HTTP/1.1" 
    enableLookups="false" redirectPort="8443" acceptCount="100" 
    connectionTimeout="20000" disableUploadTimeout="true"/> 

<!-- Define a SSL HTTP/1.1 Connector on port 8443 
    This connector uses the JSSE configuration, when using APR, the 
    connector should be using the OpenSSL style configuration 
    described in the APR documentation --> 

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" 
      maxThreads="150" scheme="https" secure="true" 
      clientAuth="false" sslProtocol="TLS" keystoreFile="conf/sds/keystore"/> 

配置和這裏的web.xml配置

<security-constraint> 
    <web-resource-collection> 
    <web-resource-name>SUCTR</web-resource-name> 
    <url-pattern>/*</url-pattern>  
    </web-resource-collection> 
    <user-data-constraint> 
    <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
    </user-data-constraint> 
</security-constraint> 

我一直在使用默認的端口80和443,並在網址中使用模式的具體路徑嘗試但仍然不起作用。我不確定我在這裏做錯了什麼,請你指點我正確的方向。

感謝。

+0

[此鏈接](HTTP:/ /www.journaldev.com/160/steps-to-configure-ssl-on-tomcat-and-setup-auto-redirect-from-http-to-https)解釋了這個過程。 – Adil 2016-04-12 09:54:28

+0

是否有可能端口號保持不變,只有重定向到https? – shzyincu 2017-04-05 09:34:17

回答

0

看起來沒錯。我假設你正在關閉安全約束標記。嘗試將網址格式更改爲「/ APP_URI/*」,然後查看訪問該應用程序是否有所幫助。

10

編輯在web.xml

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>App_nmae</web-resource-name> 
     <url-pattern>/*</url-pattern> 
     <http-method>GET</http-method> 
     <http-method>POST</http-method> 
    </web-resource-collection> 

    <user-data-constraint> 
     <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
    </user-data-constraint> 
</security-constraint> 

編輯在sever.xml

<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" 
      maxThreads="150" scheme="https" secure="true" 
      clientAuth="false" sslProtocol="TLS" 
      keystoreFile="/opt/apache-tomcat-6.0.13/.keystore" 
      keystorePass="changeit"/> 

它爲我工作..你可以試試

+0

是否有可能端口號保持不變,只有重定向到https? – shzyincu 2017-04-05 09:34:10