{"id":1159,"date":"2011-09-13T21:39:27","date_gmt":"2011-09-14T05:39:27","guid":{"rendered":"http:\/\/www.codebelay.com\/blog\/?p=1159"},"modified":"2019-10-29T16:31:50","modified_gmt":"2019-10-29T22:31:50","slug":"upgrade-your-rails-facebook-app-to-ssl","status":"publish","type":"post","link":"https:\/\/www.codebelay.com\/blog\/2011\/09\/13\/upgrade-your-rails-facebook-app-to-ssl\/","title":{"rendered":"Upgrade Your Rails Facebook App to SSL"},"content":{"rendered":"<p>On October 1st of this year, <a href=\"https:\/\/developers.facebook.com\/blog\/post\/499\/\">Facebook will be requiring that all apps on Facebook must support HTTPS (SSL)<\/a>.<\/p>\n<p>I&#8217;ve provided a guide below which I&#8217;ve used for apps I&#8217;ve worked on that are Rails based.<\/p>\n<p>This guide shows you how to change your Rails Facebook App into an app that supports SSL using <a href=\"http:\/\/www.modrails.com\/index.html\">Passenger<\/a> and Apache2.<\/p>\n<p><strong>Step 1: Get an SSL cert or roll your own.<br \/>\n<\/strong><\/p>\n<p><a href=\"http:\/\/www.dreamhost.com\/\">Dreamhost.com<\/a> made it very easy to add an SSL cert for just $15.00 \/ year.<\/p>\n<p>I tried out my app out using a locally signed certificate which seemed to work just fine:<\/p>\n<div style=\"padding: 5px; color: #fff; background: #000\">\nopenssl genrsa -des3 -out server.key 2048<br \/>\nopenssl req -new -key server.key -out server.csr<br \/>\ncp server.key server.key.org<br \/>\nopenssl rsa -in server.key.org -out server.key<br \/>\nopenssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt<\/div>\n<p><strong>Step 2: Install and compile Apache 2<br \/>\n<\/strong><br \/>\nGet the latest version of Apache: <a href=\"http:\/\/httpd.apache.org\/download.cgi\">http:\/\/httpd.apache.org\/download.cgi<\/a>.<\/p>\n<p>Configure and compile Apache:<br \/>\n.\/configure &#8211;prefix=\/usr\/local\/apache2 &#8211;enable-rewrite &#8211;enable-so &#8211;enable-ssl<br \/>\nmake &amp;&amp; make install<\/p>\n<p><strong>Step 3: Configure your Rails app<br \/>\n<\/strong><br \/>\ngem install passenger<br \/>\npassenger-install-apache2-module<\/p>\n<p><strong>Step 4: Edit your Apache 2 config files:<br \/>\n<\/strong><br \/>\nEdit httpd.conf. For example:<\/p>\n<div style=\"padding: 5px; color: #fff; background: #000\">\n<pre style=\"color: #fff; background: #000;\">LoadModule fcgid_module modules\/mod_fcgid.so\nLoadModule passenger_module \/Users\/jimbarcelona\/.rvm\/gems\/ruby-1.9.2-p290\/gems\/passenger-3.0.8\/ext\/apache2\/mod_passenger.so\nPassengerRoot \/Users\/jimbarcelona\/.rvm\/gems\/ruby-1.9.2-p290\/gems\/passenger-3.0.8\nPassengerRuby \/Users\/jimbarcelona\/.rvm\/wrappers\/ruby-1.9.2-p290\/ruby\n\n<directory \"=\"\" users=\"\" jimbarcelona=\"\" rails_apps\"=\"\">\n    Options Indexes FollowSymLinks\n    AllowOverride All\n    Order allow,deny\n    Allow from all\n<\/directory>\n\nInclude conf\/extra\/httpd-vhosts.conf\nInclude conf\/extra\/httpd-ssl.conf\n\n<ifmodule mod_fcgid.c=\"\">\nIPCCommTimeout 40\nIPCConnectTimeout 10\n\n# TODO: change this to production if you are on production\nDefaultInitEnv RAILS_ENV development\nSocketPath \/tmp\/fcgidsock\n<\/ifmodule>\n<\/pre>\n<\/div>\n<p>Edit extra\/httpd-vhosts.conf:<\/p>\n<div style=\"padding: 5px; color: #fff; background: #000\">\n<pre style=\"color: #fff; background: #000;\"><virtualhost *:80=\"\">\n  ServerName berkeley.l33tcave.com\n  ServerAdmin wwwadmin@berkeley.l33tcave.com\n  DocumentRoot \/Users\/jimbarcelona\/rails_apps\/github\/hipsterhookups.com\/public\n  ErrorLog \/usr\/local\/apache2\/logs\/rails_error_log\n  RewriteEngine On\n  <directory users=\"\" jimbarcelona=\"\" rails_apps=\"\" github=\"\" hipsterhookups.com=\"\" public=\"\">\n    AllowOverride All\n    Options -MultiViews\n  <\/directory>\n  RailsEnv development\n<\/virtualhost>\n<\/pre>\n<\/div>\n<p>Edit extra\/httpd-ssl.conf:<\/p>\n<div style=\"padding: 5px; color: #fff; background: #000\">\n<pre style=\"color: #fff; background: #000;\">#   General setup for the virtual host\nDocumentRoot \"\/Users\/jimbarcelona\/rails_apps\/github\/hipsterhookups.com\/public\"\nServerName berkeley.l33tcave.com:443\nServerAdmin you@example.com\nErrorLog \"\/usr\/local\/apache2\/logs\/error_log\"\nTransferLog \"\/usr\/local\/apache2\/logs\/access_log\"\n\n# needed for rails\nOptions Indexes ExecCGI FollowSymLinks\nRewriteEngine On\nRailsEnv development\n\n\nAddHandler fcgid-script .fcgi\n\n  <directory users=\"\" jimbarcelona=\"\" rails_apps=\"\" github=\"\" hipsterhookups.com=\"\" public=\"\">\n    AllowOverride All\n    Options -MultiViews\n  <\/directory>\n<\/pre>\n<\/div>\n<p>Be sure to add your SSL certs in the httpd-ssl.conf too!<\/p>\n<p><strong>Step 5: Start Apache<br \/>\n<\/strong><\/p>\n<p># check syntax<br \/>\napachectl configtest<br \/>\n# start apache<br \/>\napachectl start<\/p>\n<p><strong>Step 6:<\/strong> Go to facebook and use https for canvas URLs<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On October 1st of this year, Facebook will be requiring that all apps on Facebook must support HTTPS (SSL). I&#8217;ve provided a guide below which I&#8217;ve used for apps I&#8217;ve worked on that are Rails based. This guide shows you how to change your Rails Facebook App into an app that supports SSL using Passenger [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[342,4,108,107,33],"tags":[57,366,114,365],"class_list":["post-1159","post","type-post","status-publish","format-standard","hentry","category-coding-2","category-how-to","category-ruby","category-ruby-on-rails","category-webapps","tag-facebook","tag-facebook-apps","tag-rails","tag-ssl"],"_links":{"self":[{"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/posts\/1159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/comments?post=1159"}],"version-history":[{"count":0,"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/posts\/1159\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/media?parent=1159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/categories?post=1159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/tags?post=1159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}