Wednesday, July 27, 2016

ColdFusion to Node.js Conversion Part 1

This multi-part post will be community comment driven, which basically means that in an effort to not spend too much time on details that might not matter to the viewers out there, I am only going to share the details which I think are important at the time of publishing the posts. If people (or bots) comment and want more details, I will add them to the original post. As always, constructive criticism is always welcome.

Since I am currently using the CFWheels framework (which is inspired by Ruby on Rails or RoR), I chose to try out the Sails.js framework for Node.js (which is also similar to Rails).

1st thing I did was get Node and Apache working together by adding this to my Apache vhost(VirtualHost) block:
ProxyRequests on
ProxyPass / http://localhost:8124/
And adding this to my hosts file (/etc/hosts):       mynewapp.node www.mynewapp.node

This allows me to setup an alias in my host file and reference the URL as you normally would without adding the portnumber on the end of the URL. Instead of having to use http://localhost:8124/ , I can now use http://mynewapp.node
After that I installed the "sails-mysql" npm package in order to get the app working with my existing MySQL database.
npm install sails-mysql --save

The next thing I did, because one very frustrating thing you will find is that you have to "lower" then "re-lift" your sails app after every change you make. I installed sails-hook-autoreload to take care of this for me as I make code changes.
npm install sails-hook-autoreload --save-dev
// I used "--save-dev" instead of "--save" above because this package is not required in a production setting.
NOTE: create a "[your-sails-app]/config/autoreload.js" file with at least the following configuration:
module.exports.autoreload = {
  active: true,
  overrideMigrateSetting: false
Otherwise the overrideMigrateSetting will be defaulted to true and sets the "module.exports.models.migrate" setting to "alter" which will wipe out any database tables you have setup models for!! This is a good time to mention taking frequent backups of your database. Since I am using an existing MySQL database I am using the "module.exports.models.migrate = safe" setting for both development and production environments.

to be continued....

Tuesday, June 14, 2016

Bitnami WordPress htaccess Redirect for Author Pages

As their page notes, for security purposes, the htaccess configuration has been moved outside of the webroot and AllowOverride is set to "None"
In this instance I have an EC2 instance spun up from a BitNami (HVM) AMI.
The default file to edit is

Make a backup of the file before you edit.
Add this block anywhere in the file to redirect all author landing pages to the home page.

<Directory /opt/bitnami/apps/wordpress/htdocs/>
    RedirectMatch 301 "^/author/.*"
Customize to your liking if you would rather redirect to a different page.
When you're done editing, run this to restart apache, then test your changes.

sudo /opt/bitnami/ restart apache
/* Joey */