I was able to fix this issue my-self.
The main issue was the nodejs version I was using. When you switch to nodejs 7, things go much smoother.
Here are the steps I followed:
- Created a server instance in amazon web service using ubuntu-xenial-16.04-amd64-server image
- Did following on using putty terminal. (You need to create a key file and convert it using puttygen in order to connect)
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential redis-server mongodb nginx python
sudo apt-get install git
cd /opt
sudo git clone GitHub - openhab/openhab-cloud: Cloud companion for openHAB instances
cd openhab-cloud
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install nodejs
npm install
cp config-development.json config.json
sudo nano config.json
- My config.json file looks like this
{ "system": { "host": "my.domain.com", "port": "80", "protocol": "http", "logging": "info", "subDomainCookies": false, "muteNotifications": false }, "express":{ "key" : "some express key" }, "apn" : { "gateway": "gateway.push.apple.com", "cert": "certs/aps/aps_production_cert.pem", "key": "certs/aps/aps_production_key.pem", "passphrase": "passphrase" }, "gcm" : { "jid": "something@gcm.googleapis.com", "password": "password" }, "ifttt" : { "iftttChannelKey" : "key", "iftttTestToken" : "token" }, "mail": { "host" : "smtp", "port" : 465, "user" : "foo@bar.com", "pass" : "password" }, "mongodb": { "hosts": ["127.0.0.1"], "db": "openhab" }, "redis": { "host": "127.0.0.1", "port": "6379" }, "mailer": { "host" : "smtp", "port": 465, "secureConnection": true, "user": "foo@bar.com", "password": "password", "from": "openHAB Cloud <your@email.address>" }, "legal": { "terms" : "", "policy": "" }, "registration_enabled": true }
- Then I did my ngnix server related setup as below
sudo cp /opt/openhab-cloud/etc/nginx_openhabcloud.conf /etc/nginx/sites-available/default
sudo nano /etc/nginx/sites-enabled/default
This is how my ngnix setup looks like. Change MY_SERVER_NAME to your servers IP or domain name
server { listen 443 ssl default_server; ssl_certificate /etc/letsencrypt/live/MY_SERVER_NAME/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/MY_SERVER_NAME/privkey.pem; add_header Strict-Transport-Security "max-age=31536000"; charset utf-8; access_log /var/log/nginx/openhab-cloud.org-access.log; error_log /var/log/nginx/openhab-cloud.org-error.log; client_max_body_size 300m; location /css { alias /opt/openhab-cloud/public/css; } location /js { alias /opt/openhab-cloud/public/js; } location /img { alias /opt/openhab-cloud/public/img; } location /bootstrap { alias /opt/openhab-cloud/public/bootstrap; } location /font-icons { alias /opt/openhab-cloud/public/font-icons; } location /fonts { alias /opt/openhab-cloud/public/fonts; } location /js-plugin { alias /opt/openhab-cloud/public/js-plugin; } location /downloads { alias /opt/openhab-cloud/public/downloads; } location / { proxy_pass http://localhost:3000; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Real-IP $remote_addr ; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ; proxy_set_header X-Forwarded-Proto https; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name MY_SERVER_NAME; return 301 https://$server_name$request_uri; }
- Then I tested everything to make sure they works without errors:
sudo node app.js
sudo service ngnix restart
You should see openhab welcome page at your servers ip if all the above has been properly setup.
- Making everything run at boot
sudo npm install pm2 -g
sudo pm2 start /opt/opehab-cloud/app.js
sudo pm2 save
Thant was it! Enjoy!!!