配置webapp.runner以在开发环境中接受https和http流量

时间:2013-10-17 16:20:27

标签: tomcat heroku https

我有一个heroku项目,我在生产环境中成功使用了https。我不知道如何在我的开发环境中配置webapp.runner(嵌入式tomcat)以接受http和https上的连接。这有配置吗?或者我应该抓取源文件并编辑代码?现在我在我的开发环境中将所有https域切换到http,但这并不理想,我无法看到https功能是否正常工作而没有部署到heroku。

2 个答案:

答案 0 :(得分:1)

由于缺乏其他回复,我尝试回答这个问题,但我不是Heroku用户。

我认为这取决于您如何安装/启动webapp.runner。

可以为此配置Tomcat。搜索包含Tomcat服务定义的文件“server.xml”。寻找以下内容:

<Connector port="8080" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           URIEncoding="UTF-8"
           redirectPort="8443" />

要启用HTTPS,您需要按照http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html上的指南进行更改。

但请注意,在Heroku下,HTTPS应由https://devcenter.heroku.com/articles/http-routing按平衡器处理,我认为您的应用程序实际上是通过HTTP访问的。换句话说,您在Heroku中的应用程序将不会收到HTTPS流量。

答案 1 :(得分:1)

您无法在Heroku上“手动”配置SSL,您需要获取Heroku的SSL端点附加组件:https://addons.heroku.com/ssl

本文详细介绍了安装过程,设置非常简单:https://devcenter.heroku.com/articles/ssl-endpoint


更新以更好地回答海报的问题

这是如何使用maven的jetty插件在本地运行您的应用程序:

第1步:将其添加到您的开发资料下的pom.xml中:

   <plugin>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>jetty-maven-plugin</artifactId>
      <version>8.1.4.v20120524</version>
      <configuration>
         <webAppConfig>
            <contextPath>/</contextPath>
         </webAppConfig>
         <connectors>
            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
               <port>8080</port>
               <maxIdleTime>60000</maxIdleTime>
            </connector>
            <connector implementation="org.eclipse.jetty.server.ssl.SslSocketConnector">
               <port>8443</port>
               <maxIdleTime>60000</maxIdleTime>
               <keystore>${project.build.directory}/jetty-ssl.keystore</keystore>
               <password>jetty6</password>
               <keyPassword>jetty6</keyPassword>
            </connector>
         </connectors>
      </configuration>
   </plugin>
   <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>keytool-maven-plugin</artifactId>
      <executions>
         <execution>
            <phase>generate-resources</phase>
            <id>clean</id>
            <goals>
               <goal>clean</goal>
            </goals>
         </execution>
         <execution>
            <phase>generate-resources</phase>
            <id>genkey</id>
            <goals>
               <goal>genkey</goal>
            </goals>
         </execution>
      </executions>
      <configuration>
         <keystore>${project.build.directory}/jetty-ssl.keystore</keystore>
         <dname>cn=localhost</dname>
         <keypass>jetty6</keypass>
         <storepass>jetty6</storepass>
         <alias>jetty6</alias>
         <keyalg>RSA</keyalg>
      </configuration>
   </plugin>

第2步:运行应用

mvn clean jetty:run -Pdevelopment