Set up Google Cloud Platform + MEAN stack in 5mins

I believe in Google products, so it’s thus quite naturally that I use Google Cloud Platform to host my websites, apps, etc. GCP proposes a lot of pre-configured images for all your needs: blog, os, database, crm, or developer tools and infra like:

  • Jenkins
  • GitLab
  • Trac
  • NodeJS
  • MEAN
  • MySQL
  • Ruby
  • Cassandra

Images are delivered with all the tools you need to work efficiently! For example, the MEAN stack came with MongoDB, NodeJS, Express, Git, etc.

Well 🙂

But, a little configuration is needed to make your app listening on your custom port (3000 for example)

Steps

  1. Launch your server SSH console from Google Cloud Platform (Bitnami)
  2. Clone the project under /home/user/apps/
  3. Open up port 3000 in your Google Compute Network Firewall : Your VMs > Edit > Network > Click on default network_google_clud_mean_settingup
  4. Launch your own project on port 3000 (using your favorite grunt/node server command) and test if http://SERVER_IP:3000 works ? If it’s OK, go to step 5
  5. Edit the file opt/bitnami/apache2/conf/bitnami/bitnami.conf and replace the content with the configuration below (it’s only a proxy pass to route your server to the 3000 port)

Virtual Host Configuration

    <IfVersion < 2.3 >
      NameVirtualHost *:80
      NameVirtualHost *:443
    </IfVersion>

    <VirtualHost _default_:80>
    #  DocumentRoot "/opt/bitnami/apache2/htdocs"
    #  <Directory "/opt/bitnami/apache2/htdocs">
    #    Options FollowSymLinks MultiViews
    #    AddLanguage en en
    #    LanguagePriority en
    #    ForceLanguagePriority Prefer Fallback

    #    AllowOverride All
    #    <IfVersion < 2.3 >
    #      Order allow,deny                          
    #      Allow from all
    #    </IfVersion>
    #    <IfVersion >= 2.3 >
    #      Require all granted
    #    </IfVersion>
    #  </Directory>

    # Error Documents
      ErrorDocument 503 /503.html

    # Bitnami applications installed with a prefix URL (default)
    #  Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"

    # Redirect to port 3000 (proxy pass)
      ServerAdmin youremail@gmail.com
      ServerName yourservername.fr
      ProxyPass / http://localhost:3000/
      ProxyPassReverse / http://localhost:3000/
      ProxyPreserveHost On

    </VirtualHost>

    # Default SSL Virtual Host configuration.

    <IfModule !ssl_module>
      LoadModule ssl_module modules/mod_ssl.so
    </IfModule>

    Listen 443
    SSLProtocol all -SSLv2 -SSLv3
    SSLHonorCipherOrder on
    SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !EDH !RC4"
    SSLPassPhraseDialog  builtin
    SSLSessionCache "shmcb:/opt/bitnami/apache2/logs/ssl_scache(512000)"
    SSLSessionCacheTimeout  300

    <VirtualHost _default_:443>
      DocumentRoot "/opt/bitnami/apache2/htdocs"
      SSLEngine on
    SSLCertificateFile "/opt/bitnami/apache2/conf/server.crt"
    SSLCertificateKeyFile "/opt/bitnami/apache2/conf/server.key"

      <Directory "/opt/bitnami/apache2/htdocs">
        Options FollowSymLinks MultiViews
        AddLanguage en en
        LanguagePriority en
        ForceLanguagePriority Prefer Fallback
        AllowOverride All
        <IfVersion < 2.3 >
          Order allow,deny                          
          Allow from all
        </IfVersion>
        <IfVersion >= 2.3 >
          Require all granted
        </IfVersion>
      </Directory>
      # Error Documents
      ErrorDocument 503 /503.html

      # Bitnami applications installed with a prefix URL (default)
      Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
    </VirtualHost>
    # Bitnami applications that uses virtual host configuration
    Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf"
    # Status
    ExtendedStatus on
    <VirtualHost _default_:80>
    ServerName local-stackdriver-agent.stackdriver.com
    <Location /server-status>
      SetHandler server-status
      Order deny,allow
      Deny from all
      Allow from 127.0.0.1
    </Location>
    </VirtualHost>
  1. Restart apache with this command sudo /opt/bitnami/ctlscript.sh restart apache
  2. Now check your server IP in your favorite browser (chrome probably?), and your project should run there.

16 Comments Set up Google Cloud Platform + MEAN stack in 5mins

  1. diamond painting

    849982 880905Having been basically seeking at valuable weblog articles with regard towards the project research when My partner and i happened to stumble on yours. Thanks for this practical details! 489776

    Reply
  2. dich vu seo

    932297 629829Thank you for every other informative web site. Exactly where else could I get that type of information written in such a perfect means? Ive a mission that Im just now operating on, and Ive been at the appear out for such info. 643505

    Reply
  3. gửi hàng đi mỹ

    534698 931229These kinds of Search marketing boxes normally realistic, healthy and balanced as a result receive just about every customer service necessary for some product. Link Building Services 102937

    Reply
  4. 3d modeling app

    906386 795625An fascinating discussion is worth comment. I believe that you ought to write regarding this subject, it may not be a taboo topic but usually persons are too couple of to chat on such topics. To an additional location. Cheers 351079

    Reply

Leave a Reply to Davidnap Cancel reply

Your email address will not be published.