遅い回答ですが、代替の構成駆動型アプローチは、前の回答で述べたのと同じプロキシヘッダー (など)を処理するTomcat と組み合わせてrequires-channel="https"
、さまざまなタグで Spring Security を使用することです。バルブは、プロキシ ヘッダーに基づいて の動作を変更し、コネクタが実際に受信したプロトコルではなく、プロキシによって報告されたプロトコルを反映します。したがって、Do the Right Thing に依存する Spring などのフレームワークは、SSL がオフロードされたときに適切に動作します。<sec:intercept-url>
RemoteIpValve
x-forwarded-proto
HttpServletRequest.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
にオーバーライドするように設定します。