Showing posts with label Heroku. Show all posts
Showing posts with label Heroku. Show all posts

Saturday, October 25, 2014

Detecting SSL in PHP on Heroku

In order to have a certified connection, websites would like to the user to use HTTPS instead of HTTP. However, sometimes we can't control what's the URL that the user request, which means that the user may ask for http://facebook.com instead of https://facebook.com.

So, to solve this problem, we detect that if the user is requesting HTTP URLs. And, if yes, response 301 to the user to ask him to redirect to our HTTPS site.

Normal, if we implement it in PHP, add the following code in the front of the file:


However, on Heroku, they don't have $_SERVER['HTTPS'] but $_SERVER['HTTP_X_FORWARDED_PROTO']) instead. So, we do:

Sunday, June 29, 2014

PaaS: Google AppEngine v.s. Heroku

Reference

Intro

I am putting "Reference" section as the first section in this post because that I am writing this post totally based on the refereces.

Comparison

Language Support

Google AppEngine: Python, Java, PHP, Go / Cloud SQL(MySQL compatible)
Heroku: Ruby, Java, Node.js, Python, PHP, Clojure, Scala / PostgreSQL, MongoDB, Cloudant, Redis

Comments for Google AppEngine

AppEngine’s proprietary, read-only nature results in tedious and unnecessary code refactoring; apps have to be written specifically with AppEngine in mind, API’s have to be written specifically for AppEngine, even standard Java code has to be extensively altered to fit into the AppEngine environment.

Google insists on AppEngine customers only using its BigTable non-relational database, although they have also recently added some support for CloudSQL.

Comments for Heroku

Heroku’s database-platform choices reflect a collection that is in widespread use already in the wider world.

Comments on Both

Heroku’s database-platform choices reflect a collection that is in widespread use already in the wider world.


My Summary

I only have a little developing experience on both PaaS platforms. However, from the referece I found, more people suggest Heroku than Google AppEngine. It's because that Google AppEngine is tie-in, lack of flexibility, and hard to move to regular VPS if needed.

IaaS, PaaS, SaaS

Intro

To start a new web-based project (mainly HTTP/HTTPS-related things), we do have multiple choices for the platform. We can host a whole virtual machine, like AWS or Linode. Or, we can host put our code on Google Appengine or Heroku. They all have different pros and cons, and we should pick the one which matches the purpose of the project.

SaaS: Software as a Service

Examples

  • Gmail
  • Google+

PaaS: Platform as a Service

One can develop applications and let them execute on top of the platform which take care of the execution.

Vendors manage:

  • runtime
  • middleware
  • O/S
  • virtualizatoin
  • server
  • storage
  • networking

Users manage:

  • application
  • data

Examples

  • Heroku
  • Google App Engine

IaaS: Infrastructure as a Service

Users buy fully outsource service (the whole virtual machine)

Examples

  • AWS(Amazon Web Services)
  • Linode

Reference