The configuration will be:
There is the fat cloud which contains my small host with a unique IP-Address.
I've been using digital ocean to setup the system at http://gallery.code-lounge.com.
To map the IP-Address to a more readable name I've booked an address at a DNS-Provider. Mine is hosteurope. Eventually the requested page will be delivered to the user.
The application stack on the server contains NodeJS, node-forever and nginx. Nginx is used as a proxy before nodejs. Forever makes sure the script runs forever and won't stop by an error.
I've chosen the distribution Ubuntu 14.04 for my host and my further description will be related to Ubuntu.
Copy the gallery script to the server
I've used the directory /usr/share/nginx/www/gallery for the gallery.
Clone the repository and create the required symlinks explained in part 1.
nginx
First I've added the recommended repository from the nginx wiki to my sources. This will make sure I have a more current version available than the repository that is included into Ubuntu by default.apt-get install nginx will install nginx.
Now open the /etc/nginx/nginx.conf file and paste the following code into the http part.
upstream gallery.code-lounge.com {
server 127.0.0.1:3002;
}
server {
listen 0.0.0.0:80;
server_name gallery.code-lounge.com;
access_log /var/log/nginx/gallery.code-lounge.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://gallery.code-lounge.com/;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
client_max_body_size 10M;
}
Now replace all occurrences of gallery.code-lounge.com with your own hostname. Save the file and reload nginx with service nginx reload. Testing the host will provide a bad gateway response since nodejs is not setup yet.
NodeJS
Same like for nginx I want to have most current version. Therefor I've executed the curl command recommended in the official node js installation instructions.apt-get install nodejs will do the installation.
Node-Forever
Now install forever with npm install -g forever.The server can be started now with using forever start /usr/share/nginx/www/gallery/app.js
forever list will show you the currently running scripts
forever stop index will stop the script.
You should the the folders of your folders.json after typing the url into your browser.
No comments:
Post a Comment