heroku local web - 重定向到 https://localhost,失败
heroku local web - redirects to https://localhost, which fails
我在让我的 Spring 应用部署到本地用户 heroku local web
时遇到了一些问题。 运行在测功机上没问题。
这是我的 Procfile 中的内容:
web: java $JAVA_OPTS -jar web/target/dependency/webapp-runner.jar --expand-war --enable-compression --port $PORT web/target/*.war
代码中的任何地方都没有提及 WebSecurityConfig 或 WebSecurityConfigurerAdapter。
这看起来在本地部署得很好:
MacBook-Pro:motherbrain brianstinar$ heroku local web
[OKAY] Loaded ENV .env File as KEY=VALUE Format
4:40:47 PM web.1 | Expanding gwd-web-1.4.3.war into /Users/brianstinar/Noventum/GeeksWhoDrink/motherbrain/target/tomcat.5000/webapps/expanded
4:40:47 PM web.1 | Adding Context for /Users/brianstinar/Noventum/GeeksWhoDrink/motherbrain/target/tomcat.5000/webapps/expanded
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.coyote.AbstractProtocol init
4:40:48 PM web.1 | INFO: Initializing ProtocolHandler ["http-nio-5000"]
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
4:40:48 PM web.1 | INFO: Using a shared selector for servlet write/read
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.catalina.core.StandardService startInternal
4:40:48 PM web.1 | INFO: Starting service Tomcat
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.catalina.core.StandardEngine startInternal
4:40:48 PM web.1 | INFO: Starting Servlet Engine: Apache Tomcat/8.0.47
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.catalina.loader.WebappLoader buildClassPath
4:40:48 PM web.1 | INFO: Unknown loader jdk.internal.loader.ClassLoaders$AppClassLoader@55054057 class jdk.internal.loader.ClassLoaders$AppClassLoader
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment
4:40:48 PM web.1 | INFO: No global web.xml found
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.jasper.servlet.TldScanner scanJars
4:40:48 PM web.1 | INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.catalina.core.ApplicationContext log
4:40:48 PM web.1 | INFO: Initializing Spring root WebApplicationContext
4:40:55 PM web.1 | WARNING: An illegal reflective access operation has occurred
4:40:55 PM web.1 | WARNING: Illegal reflective access by org.springframework.util.ReflectionUtils (file:/Users/brianstinar/Noventum/GeeksWhoDrink/motherbrain/target/tomcat.5000/webapps/expanded/WEB-INF/lib/spring-core-5.1.6.RELEASE.jar) to constructor java.math.BigInteger(long)
4:40:55 PM web.1 | WARNING: Please consider reporting this to the maintainers of org.springframework.util.ReflectionUtils
4:40:55 PM web.1 | WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
4:40:55 PM web.1 | WARNING: All illegal access operations will be denied in a future release
4:41:32 PM web.1 | Dec 15, 2020 4:41:32 PM org.apache.coyote.AbstractProtocol start
4:41:32 PM web.1 | INFO: Starting ProtocolHandler ["http-nio-5000"]
但是如果我去 http://localhost:5000/ 我得到一个 302 到 https://localhost 和一个 Set-Cookie:
Set-Cookie: JSESSIONID=E97001499B33CE33B29FB1D53A14DBFB; Path=/; HttpOnly
我试过设置
server.session.cookie.secure=false
secure.cookie=false
server.servlet.session.cookie.secure=false
在我的 version.properties 中,这似乎没有帮助。
我还补充了:
<!-- didn't work
<server>
<session>
<cookie>
<secure>false</secure>
</cookie>
</session>
</server>
-->
<server> <!-- also didn't work -->
<serverlet>
<session>
<cookie>
<secure>false</secure>
</cookie>
</session>
</serverlet>
</server>
给我的 web/src/main/webapp/WEB-INF/web.xml.
所以,我不确定发生了什么。我想我不明白如何正确设置这个指令。我在获得这个 运行 Tomcat 方面取得了一些进展,但由于我继承了这个项目,mvn 最 correct/updated 用于实际的 heroku 部署。我想让它在本地进行以实现更快速的开发,我宁愿不在 Tomcat 中处理 443 和 80 的自签名 SSL,但现在这是我能看到进展的唯一途径。
我也尝试 运行使用 Tomcat 7 maven 插件来解决这个问题,就像这样:
mvn -X org.apache.tomcat.maven:tomcat7-maven-plugin:2.0:run -Dtomcat.ignorePackaging=true
同样的错误。
现在我正在设置 Tomcat 7,并且实际上在 443 上通过 https:// 在本地将 SSL 证书安装到 运行。None 其中运行宁 Tomcat 的便利实际上看起来很方便。
我安装了一个蛇油 SSL 证书,在获得 Tomcat 到 运行 之后没有任何便利(没有 maven 插件,没有 heroku 本地插件......)此外,我的应用程序不是设计到 运行 子目录中,这主要搞砸了静态资源托管被硬编码到网络根目录。
因此,我的应用程序具有需要 SSL 的依赖项(特别是 jSessionid),以及其他降低灵活性的架构决策。
我在让我的 Spring 应用部署到本地用户 heroku local web
时遇到了一些问题。 运行在测功机上没问题。
这是我的 Procfile 中的内容:
web: java $JAVA_OPTS -jar web/target/dependency/webapp-runner.jar --expand-war --enable-compression --port $PORT web/target/*.war
代码中的任何地方都没有提及 WebSecurityConfig 或 WebSecurityConfigurerAdapter。
这看起来在本地部署得很好:
MacBook-Pro:motherbrain brianstinar$ heroku local web
[OKAY] Loaded ENV .env File as KEY=VALUE Format
4:40:47 PM web.1 | Expanding gwd-web-1.4.3.war into /Users/brianstinar/Noventum/GeeksWhoDrink/motherbrain/target/tomcat.5000/webapps/expanded
4:40:47 PM web.1 | Adding Context for /Users/brianstinar/Noventum/GeeksWhoDrink/motherbrain/target/tomcat.5000/webapps/expanded
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.coyote.AbstractProtocol init
4:40:48 PM web.1 | INFO: Initializing ProtocolHandler ["http-nio-5000"]
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
4:40:48 PM web.1 | INFO: Using a shared selector for servlet write/read
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.catalina.core.StandardService startInternal
4:40:48 PM web.1 | INFO: Starting service Tomcat
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.catalina.core.StandardEngine startInternal
4:40:48 PM web.1 | INFO: Starting Servlet Engine: Apache Tomcat/8.0.47
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.catalina.loader.WebappLoader buildClassPath
4:40:48 PM web.1 | INFO: Unknown loader jdk.internal.loader.ClassLoaders$AppClassLoader@55054057 class jdk.internal.loader.ClassLoaders$AppClassLoader
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment
4:40:48 PM web.1 | INFO: No global web.xml found
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.jasper.servlet.TldScanner scanJars
4:40:48 PM web.1 | INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
4:40:48 PM web.1 | Dec 15, 2020 4:40:48 PM org.apache.catalina.core.ApplicationContext log
4:40:48 PM web.1 | INFO: Initializing Spring root WebApplicationContext
4:40:55 PM web.1 | WARNING: An illegal reflective access operation has occurred
4:40:55 PM web.1 | WARNING: Illegal reflective access by org.springframework.util.ReflectionUtils (file:/Users/brianstinar/Noventum/GeeksWhoDrink/motherbrain/target/tomcat.5000/webapps/expanded/WEB-INF/lib/spring-core-5.1.6.RELEASE.jar) to constructor java.math.BigInteger(long)
4:40:55 PM web.1 | WARNING: Please consider reporting this to the maintainers of org.springframework.util.ReflectionUtils
4:40:55 PM web.1 | WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
4:40:55 PM web.1 | WARNING: All illegal access operations will be denied in a future release
4:41:32 PM web.1 | Dec 15, 2020 4:41:32 PM org.apache.coyote.AbstractProtocol start
4:41:32 PM web.1 | INFO: Starting ProtocolHandler ["http-nio-5000"]
但是如果我去 http://localhost:5000/ 我得到一个 302 到 https://localhost 和一个 Set-Cookie:
Set-Cookie: JSESSIONID=E97001499B33CE33B29FB1D53A14DBFB; Path=/; HttpOnly
我试过设置
server.session.cookie.secure=false
secure.cookie=false
server.servlet.session.cookie.secure=false
在我的 version.properties 中,这似乎没有帮助。
我还补充了:
<!-- didn't work
<server>
<session>
<cookie>
<secure>false</secure>
</cookie>
</session>
</server>
-->
<server> <!-- also didn't work -->
<serverlet>
<session>
<cookie>
<secure>false</secure>
</cookie>
</session>
</serverlet>
</server>
给我的 web/src/main/webapp/WEB-INF/web.xml.
所以,我不确定发生了什么。我想我不明白如何正确设置这个指令。我在获得这个 运行 Tomcat 方面取得了一些进展,但由于我继承了这个项目,mvn 最 correct/updated 用于实际的 heroku 部署。我想让它在本地进行以实现更快速的开发,我宁愿不在 Tomcat 中处理 443 和 80 的自签名 SSL,但现在这是我能看到进展的唯一途径。
我也尝试 运行使用 Tomcat 7 maven 插件来解决这个问题,就像这样:
mvn -X org.apache.tomcat.maven:tomcat7-maven-plugin:2.0:run -Dtomcat.ignorePackaging=true
同样的错误。
现在我正在设置 Tomcat 7,并且实际上在 443 上通过 https:// 在本地将 SSL 证书安装到 运行。None 其中运行宁 Tomcat 的便利实际上看起来很方便。
我安装了一个蛇油 SSL 证书,在获得 Tomcat 到 运行 之后没有任何便利(没有 maven 插件,没有 heroku 本地插件......)此外,我的应用程序不是设计到 运行 子目录中,这主要搞砸了静态资源托管被硬编码到网络根目录。
因此,我的应用程序具有需要 SSL 的依赖项(特别是 jSessionid),以及其他降低灵活性的架构决策。