2011-03-20 147 views
24

我現在在谷歌應用引擎項目。在我的應用程序中,我只需要允許https協議。我必須限制其他協議。它應該只允許https。我在web.xml中添加了下面的代碼。https只在谷歌應用引擎

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

但部署後它可以在協議(http和https)上工作。如何限制http?

+0

你測試你部署到應用程序的相同版本?您是否嘗試刪除「」? – 2011-03-20 13:59:53

+0

我正在測試我部署的相同版本。我沒有通過刪除網絡資源名稱進行測試。讓我試試現在。謝謝。 – DonX 2011-03-20 14:07:23

回答

4

您是否使用自己的域名?目前,GAE支持* .appspot.com域的SSL only。他們已經有promising對非appspot域名的SSL支持有一段時間了,我們都在等待這方面的消息。

+2

現在支持自定義域的SSL https://support.google.com/a/answer/2644334?hl=zh-CN – 2015-02-04 19:40:01

47

可以將各個處理程序配置爲在WEB-INF文件夾中的app.yaml文件中要求HTTPS,如此處所述:Java Application Configuration Using app.yaml - Google App Engine

你只需要這兩個詞的適當url條目下添加到您的app.yaml文件:
secure: always

例如:

- url: .* 
    script: main.app 
    secure: always 

如果用戶試圖用HTTP訪問URL然後她將被自動重定向到HTTPS。很酷。

+0

現在,GAE已經爲GAE添加了對自定義域的SSL支持。 https://developers.google.com/appengine/docs/ssl?hl=fr感謝: 安全:始終是部分 – 2013-06-06 18:24:31

+0

感謝您的評論。刪除了該段落(因爲此處不提供穿透功能)。 – zengabor 2013-06-08 12:33:50

+0

我可以在沒有SSL的GAE上運行應用程序嗎? – Pokuri 2015-06-23 08:58:28

10

如果您想堅持使用「web.xml」而不是使用「app.yaml」選項(它將在部署時覆蓋您的web.xml & appengine-web.xml文件),則可以添加:

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

參考: https://cloud.google.com/appengine/docs/java/config/webxml#Security_and_Authentication

0

添加到您的web.xml文件

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