2011-03-20 149 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>