2015-09-28 25 views
10

Web uygulamasında SSL'yi yapılandırdım. Sertifikayı Tomcat'ta gerekli adımlara göre kurdum. Ben takip ediyorumApache Tomcat'te http: https adresinden 301 yönlendirmesi gerçekleştirin

öğretici ben http herhangi isteği https'ye iletilir anlamına gelir http üzerinden https kullanımını zorunlu hale getirmiştir https://www.mulesoft.com/tcat/tomcat-security

olduğunu. Ancak

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>SecureConnection</web-resource-name> 
     <url-pattern>/*</url-pattern> 
    </web-resource-collection> 
    <user-data-constraint> 
     <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
    </user-data-constraint> 
</security-constraint> 

, yönlendirme: Ben

  • <Connector port="8080" protocol="HTTP/1.1" 
    
          connectionTimeout="20000" 
    
          redirectPort="443" 
    
          proxyHost="10.1.1.1" proxyPort="80" 
    
          URIEncoding="UTF-8" 
    
          maxHttpHeaderSize="32768"/> 
    
    daha bakın benim server.xml aşağıdaki değişiklikleri yapmıştır: aşağıdaki gibi https://www.mulesoft.com/tcat/tomcat-security#sthash.6zIVA27x.dpuf

web.xml değişikliklerdir Bu gerçekleşiyor geçici re-direct yani 302. Ben 301 re-direct yani kalıcı yönlendirme kullanmak istiyorum.

Bunu nasıl başarabilirim?

+0

Bu soruya bir cevap buldunuz mu? Aynı problemim var. – Thermometer

+0

Aynı burada, sorunla ilgili herhangi bir gelişme var mı? – Default71721

+0

Google çalışanlarının şu anda "https tomcat'i zorunlu kılmak", "her zaman https tomcat" veya benzerleri için çözüm budur. https://jelastic.zendesk.com/hc/en-us/community/posts/206121996-HTTP-HTTPS-Redirection-into-the-Tomcat ayrıca bir çözüm sağlar. – koppor

cevap

2

Bu, Realm üzerinde yapılandırılmıştır. Özel Realm uygulamanızın transportGuaranteeRedirectStatus özniteliğine bakın.

https://tomcat.apache.org/tomcat-8.5-doc/config/realm.html

Ör: server.xml bunu bir 301 kullanmanız olmak için bu out-of-the-box

<Realm className="org.apache.catalina.realm.LockOutRealm"> 
    <!-- This Realm uses the UserDatabase configured in the global JNDI 
     resources under the key "UserDatabase". Any edits 
     that are performed against this UserDatabase are immediately 
     available for use by the Realm. --> 
    <Realm className="org.apache.catalina.realm.UserDatabaseRealm" 
      resourceName="UserDatabase"/> 
    </Realm> 

O bunu böylece 302 varsayılan olarak transportGuaranteeRedirectStatus set değil mi sadece transportGuaranteeRedirectStatus="301" özniteliğini en üst seviyeye ekleyin (yapılandırmanıza bağlı olarak Realms'i iç içe geçirmemiş olabilirsiniz) ve Tomcat'i yeniden başlatın.

Ör: Eğer konfigürasyonda tanımlanan bir Realm etiketi yoksa

<Realm className="org.apache.catalina.realm.LockOutRealm" transportGuaranteeRedirectStatus="301"> 
    <!-- This Realm uses the UserDatabase configured in the global JNDI 
     resources under the key "UserDatabase". Any edits 
     that are performed against this UserDatabase are immediately 
     available for use by the Realm. --> 
    <Realm className="org.apache.catalina.realm.UserDatabaseRealm" 
      resourceName="UserDatabase" /> 
    </Realm> 

, Tomcat bir NullRealm kullanarak varsayılan olacaktır. Yönlendirme'yi bu durumda geçersiz kılmak isterseniz, üzerinde ayarlanmış olan transportGuaranteeRedirectStatus özelliği ile bir NullRealm tanımlamanız gerekir.

Bu yardımcı olur umarım!

İlgili konular