我有一个heroku项目,我在我的生产环境中成功地使用了https。 我不确定如何在我的开发环境中配置 webapp.runner(嵌入式 tomcat)以接受 http 和 https 上的连接。 有配置吗? 还是我应该获取源文件并编辑代码? 现在,我正在开发环境中将所有https域切换为http,但这并不理想,如果不部署到heroku,我无法看到https功能是否正常工作。
在没有其他回应的情况下,我试图回答这个问题,但我不是 Heroku 用户。
我认为这取决于您如何安装/启动 webapp.runner .
雄猫可以为此进行配置。搜索包含 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 流量。
你不能在 Heroku 上"手动"配置 SSL,你需要获取 Heroku 的 SSL 端点附加组件:https://addons.heroku.com/ssl
本文详细介绍了安装过程,设置起来非常简单:https://devcenter.heroku.com/articles/ssl-endpoint
更新以更好地回答海报的问题
这是如何使用 maven 的码头插件在本地运行您的应用程序:
第 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