2012-08-06 18 views
6

で実行します。私は8080ポートをまったく使用したくありません。 ご存知ですか?あなたが8080にバインドし、[Tomcatの-DIR] /conf/server.xmlで定義されたコネクタを削除し、HTTPS用に別のコネクタを持っている必要があります埋め込みTomcatの-7は、私が唯一のHTTPS(8443)を使用して埋め込まれたTomcatを実行する場合にのみ、HTTPS

 

    Connector httpsConnector = new Connector(); 
    httpsConnector.setPort(httpsPort); 
    httpsConnector.setSecure(true); 
    httpsConnector.setScheme("https"); 
    httpsConnector.setAttribute("keystoreFile", appBase + "/.keystore"); 
    httpsConnector.setAttribute("clientAuth", "false"); 
    httpsConnector.setAttribute("sslProtocol", "TLS"); 
    httpsConnector.setAttribute("SSLEnabled", true); 

    Tomcat tomcat = new Tomcat(); 
    tomcat.getService().addConnector(httpsConnector); 
    tomcat.setPort(8080); 
    Connector defaultConnector = tomcat.getConnector(); 
    defaultConnector.setRedirectPort(8443); 

    tomcat.setBaseDir("."); 
    tomcat.getHost().setAppBase(appBase); 

    StandardServer server = (StandardServer) tomcat.getServer(); 
    AprLifecycleListener listener = new AprLifecycleListener(); 
    server.addLifecycleListener(listener); 

おかげ

+0

8080ポートを禁止することはできましたか? –

答えて

2

+0

実際には私はtomcatを埋め込んでいます。私はそこにserver.xmlを使用していません。プログラム的にコネクタが追加されます – Srinivas

+0

あなたのTwitterはどのように起動していますか?あなたの質問に詳細を記入できますか? – Chris

+0

編集された投稿埋め込みコード – Srinivas

0

私はちょうどhttpsConnectorを作成するための質問のスニペットを使ってみました。 keytoolcreating the keystoreはトリックをしたときに、パスワードのIセットアップにそれを設定する

httpsConnector.setAttribute("keystorePass", "YOUR-PASSWORD-HERE"); 

:私は1つの不足している行を追加する必要がありました場合を除き。

ありがとうございます!

0

TomcatインスタンスからdefaultConnectorを取得し、httpsに設定します。このように、他のコネクタはありません。

Connector defaultConnector = tomcat.getConnector(); 
    defaultConnector.setPort(8443); 
    defaultConnector.setSecure(true); 
    defaultConnector.setScheme("https"); 
    defaultConnector.setAttribute("keystorePass", "password"); 
    defaultConnector.setAttribute("keystoreFile", absolutePath + "/keystore.jks"); 
    defaultConnector.setAttribute("clientAuth", "false"); 
    defaultConnector.setAttribute("sslProtocol", "TLS"); 
    defaultConnector.setAttribute("SSLEnabled", true); 
関連する問題