遅い回答ですが、代替の構成駆動型アプローチは、前の回答で述べたのと同じプロキシヘッダー (など)を処理するTomcat と組み合わせてrequires-channel="https"、さまざまなタグで Spring Security を使用することです。バルブは、プロキシ ヘッダーに基づいて の動作を変更し、コネクタが実際に受信したプロトコルではなく、プロキシによって報告されたプロトコルを反映します。したがって、Do the Right Thing に依存する Spring などのフレームワークは、SSL がオフロードされたときに適切に動作します。<sec:intercept-url>RemoteIpValvex-forwarded-protoHttpServletRequest.isSecure()isSecure()
Heroku での SSL リダイレクトには、webapp-runner および Heroku で使用するためのバルブの構成に関する指示があります。
さらに、PropertyPlaceholderConfigurer値を環境オーバーライド可能にするために使用することをお勧めします。たとえば、Spring Security 構成では次のようになります。
<sec:intercept-url pattern="/api/**" requires-channel="${REQUIRES_CHANNEL}" access="..."/>
関連application-config.xmlするものには、次のようなものが含まれます。
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="properties" ref="applicationProperties"/>
</bean>
<bean id="applicationProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:/application-config.properties</value>
</list>
</property>
</bean>
このapplication-config.propertiesファイルはREQUIRES_CHANNEL=httpデフォルトでインクルードし、Heroku にデプロイするときheroku config:set REQUIRES_CHANNEL=httpsにオーバーライドするように設定します。