如何在 symfony 1.4 中实现 SSL?
目前我们的项目没有任何 SSL 安全性。项目中的所有 URL 都可以通过 http://www.something.com 之类的 URL 来访问。
现在我们想将其更改为 https://www.something.com。
此外,我们还创建了一些返回 Json 数据的 Web 服务。这些 Web 服务可通过 Apple iPhone 和 Blackberry 等移动设备上的 URL 进行访问。 Web 服务的 URL 以 http:// 开头。
现在我们还希望以这样的方式确保这些 Web 服务现在只能通过 https 协议(如 https://)访问
Currently our project is not having any SSL Security. All of the URLs in the project can be accessed by urls like http://www.something.com.
Now we want to change the same to https://www.something.com.
Also, we have created some webservices which are returning Json data. These webservices are accessed thorugh the urls on mobile devices such as Apple iphone and Blackberry.
Urls for the webservices begin with http://
Now we also want to secure the same in such a way that these webservices now can be accessed only through https protocol like https://
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想使用 HTTPS,则必须设置 Apache 才能这样做。有很多文章描述了如何在 Ubuntu 上做到这一点。尝试搜索“ubuntu setup ssl apache2”左右。
示例: http://www.linode.com/wiki/index.php/Apache2_SSL_in_Ubuntu
简而言之:您必须在 Apache 配置中创建一个新的 NameVirtualHost 条目,并使其侦听端口 443(默认 https 端口)并设置认证。如果您的网站是公共网站,那么我想您不想要自签名证书(浏览器会告诉用户该证书是由服务器本身签名的,因此不能信任)。在网上寻找 SSL 认证,我在我的一个项目中使用了 Verisign。认证之间不应该有任何大的差异,用户通常不知道幕后发生了什么,尽管我建议从更知名的名称购买它(用户可能更喜欢它)。
Symfony 不负责在 HTTPS 级别处理您的请求,如果您的网络服务器配置正确,请求通过 HTTPS 发出,它将加载 PHP 和 Symfony 来生成响应并通过 HTTPS 将其发回。 Symfony 可以为你做的就是将 http 之间的页面重定向到 https 站点,如果你愿意的话(或者想要限制某些页面,就像除了登录、注册和更改密码页面之外的所有内容都是不安全的)。不幸的是,我不知道有什么好的插件可以解决这个问题,但基本上你必须编写一个过滤器,在处理请求处理模块/操作之前触发任何请求。
这个来源看起来不错: http://blog .tigregroup.com/programming/creating-an-ssl-redirect-filter-in-symfony/
hth
If you want to use HTTPS you have to setup your Apache to do so. There are many articles describing how can you do it on Ubuntu. Try searching "ubuntu setup ssl apache2" or so.
Example: http://www.linode.com/wiki/index.php/Apache2_SSL_in_Ubuntu
In few words: you have to create a new NameVirtualHost entry in your Apache configuration, and make it listen to port 443 (default https port) and setup a certification. If your website is a public website then I suppose you don't want a self signed certification (the browser will tell the user that the certification is signed by the server itself, therefore it cannot be trusted). Look for an SSL certification on the net, I have used Verisign for one of my projects. There shouldn't be any big differences between certifications, users normally not aware of what is happening under the hood, although I would suggest to buy it from a more well known name (users might like it better).
Symfony is not responsible handling your requests on HTTPS level, if your webserver is configured properly, the request comes through HTTPS and it will load PHP and Symfony to generate the response and send it back through HTTPS. What Symfony can do for you is to redirect pages between the http to the https site, if you wanted to (or wanted to limit some pages, like everything is unsecure except the login, register and change password pages). Unfortunately I don't know any good plugin to solve this, but basically you have to write a filter that triggers on any request, just before the request handling module/action is being processed.
This source looks to be good: http://blog.tigregroup.com/programming/creating-an-ssl-redirect-filter-in-symfony/
hth
Hej,
将其写入您的 .htaccess 中,它就可以工作了。
Hej,
write this in your .htaccess and it works.
有两个插件可供使用:
sfSslRequirementPlugin :“为操作提供 SSL 加密支持”
和
sfSslRequirementExtraPlugin:“通过完全参数化的架构,仅在需要时使用 ssl 协议,增强应用程序安全性。该插件基于 sfSslRequirementPlugin,添加了新功能。”
There are two plugin for use:
sfSslRequirementPlugin : "Provides SSL encryption support for actions"
and
sfSslRequirementExtraPlugin: "Enhance your application security, using ssl protocol only when needed, via a fully parametrized architecture. This plugin is based on sfSslRequirementPlugin, adding new capabilities."