Web Served 8: Node.js, Redis, and real-time writing with Etherpad Lite

Status
Not open for further replies.

pokrface

Senior Technology Editor
21,531
Ars Staff
[url=http://meincmagazine.com/civis/viewtopic.php?p=24813447#p24813447:zqimzh5l said:
autodefenestrator[/url]":zqimzh5l]One thing I found: Etherpad's use of port 9001 appears to conflict with Tor.

Also, the rewrite line needs a space between "rewrite" and "^".
Thanks! Fixed. Always hard to ferret out all the typos in a piece with this many code snippets and extra formatting bits.

Looks like you're right about the potential conflict. You can change the port Etherpad runs on by editing the "port" setting at the top of "settings.json". I don't think I'll update the piece, though—I figure most folks savvy enough to be running Tor probably can figure it out.
 
Upvote
5 (5 / 0)

BluSteel

Seniorius Lurkius
25
I have really, really enjoyed this series. It has been a really great jumping off point in creating my own personal website that holds notes and other things that I can host on my own machine without relying on outside cloud services.

Etherpad lite seems like a neat tool. I've never used it but I could definitely see the benefits. I do hope that you continue with intermittent tutorials on webhosting. In particular, I think it would be really cool to see a tutorial on setting up a dropbox alternative (such as owncloud) to really extend the functionality of a home server.
 
Upvote
3 (3 / 0)

johnyma22

Seniorius Lurkius
1
@autodefenestrator You can change the port of Etherpad by Hitting up /admin/settings or by editing settings.json

@Aurich Lawson you can use the API or a plugin to see pads available and to delete existing pads.

Visit /admin/plugins to see the available plugins and one click install them :)

To get to the /admin/plugins page you need to set a username/pass in settings.json, it'd be great if Lee can do a quick write up about how to install plugins on Etherpad and maybe an authors pick of his favorites! :)
 
Upvote
3 (3 / 0)
Having tried out Etherpad about a year ago, we settled on Gobby, using a infinote server running on an Ubuntu install locally. The latest infinote server is rock solid (been running since November without a single outage)

And Gobby is, in my opinion, far superior, so long as you do not need document history. It has built in chat, full document support (folders, many documents), security communication, great performance, and so on. Etherpad felt very clunky, even when on a local network.

Gobby has replaced instant messaging and chatrooms for our development team. We have documents of the issues and talk right on the ticket itself, which allows for many simultaneous discussions, rather than the 1-2 you can have going in a chatroom.
 
Upvote
0 (0 / 0)

smg82

Seniorius Lurkius
3
When I get to the npm install redis step, I get a series of errors (starting with something along the lines of 'ueberDB is not a valid file name') and the ueberDB redis connector fails to install correctly in the /ueberDB directory.

I got around this by installing the redis connector elsewhere then moving it to the correct directory, as follows:

cd /usr/share/nginx
npm install redis
mv /node_modules/redis /usr/share/nginx/etherpad-lite/src/node_modules/ueberDB/node_modules/
rm -rf node_modules

(be careful with that last command - if you install the redis connector in a directory other than /usr/share/nginx, and that directory already had a 'node_modules' sub-directory, then skip the last command or you'll delete whatever else was already in the sub-directory)

I'm not sure why this was workaround was necessary though. There was already a node-redis module in ueberDB/node_modules, so maybe etherpad/node have preinstalled a different connector and don't want you to use the other redis connector? Any ideas?
 
Upvote
0 (0 / 0)

Collie147

Seniorius Lurkius
14
Again, Lee, fantastic series! Learning a lot here. Thanks again.

Having a wee bit of a problem and I've been trying to sort this out all week, but I'm a bit stuck at one part.

Etherpad works fine when I get it running through the server and port 9001 (e.g. http://192.168.1.2:9001) but when I load it through /etherpad/ it appears that the css isn't loading ("New Pad" icon not showing up and format is all over the place on the pad page) and when I create or open an pad I get a flash of an error about not having permission to access something and then " 'require' is undefined in http://192.168.1.2/etherpad/p/Test (line 540)" and can't do anything.

Checked nginx access and error logs, unfortunately the error logs don't point to anything, and the access logs give me a 301 error on the css and javascript files

Think I've found the problem.

"get /wiki/Main_Page HTTP/1.1" 200 5079 "http://192.168.1.2/etherpad/p/Test"
It wouldnt be the line from the wiki.conf file would it?

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
try_files $uri /wiki/index.php;
expires max;
log_not_found off;
}
 
Upvote
2 (2 / 0)

l8gravely

Ars Scholae Palatinae
737
Subscriptor++
Nice article, does a good job of explaining *why* you made various choices during the install, which I like. But a quick comment about the SSI of the text file and the cronjob. Wouldn't it be more efficient to just have nginx call the script when someone hits the page, and to cache the result for 60 seconds or so?

This way, you're not endlessly re-writing the output file, and you only put in updates when someone actually hits the etherpad web page. No sense doing work all night from 1am to 6am if no one is actually using the system, is there?
 
Upvote
0 (0 / 0)

acorbo

Seniorius Lurkius
11
[url=http://meincmagazine.com/civis/viewtopic.php?p=25044279#p25044279:2as0tpk9 said:
Collie147[/url]":2as0tpk9]change it to
"location ~* /wiki/\*.(js|css|png|jpg|jpeg|gif|ico)$" and it seems to have worked.


I had the exact same behavior on my installation. I tried your changes and it appears to be working now. Still, I'm at a loss on 'why' would a wiki location have any effect on the pad's css... Let me know the reason if you have the time, and thanks a million for posting it...
 
Upvote
0 (0 / 0)

ars_forum

Wise, Aged Ars Veteran
192
To make the pad links work per your instruction, change this:

redis-cli keys 'pad:*' |grep -Eo '^pad:[^:]+' |sed -e 's/pad://'
|sort |uniq -c |sort -rn |awk '{if ($1!="2") {print $2 }}'
|sed -e 's/.*/<a href="\/p\/&">&<\/a>/' -e 's/^/<li>/' -e 's/$/<\/li>/'
> "$PADPATH"

to this:

redis-cli keys 'pad:*' |grep -Eo '^pad:[^:]+' |sed -e 's/pad://'
|sort |uniq -c |sort -rn |awk '{if ($1!="2") {print $2 }}'
|sed -e 's/.*/<a href="\/etherpad\/p\/&">&<\/a>/' -e 's/^/<li>/' -e 's/$/<\/li>/'
> "$PADPATH"

in the getpads.sh file (if your site uses http:/yoursite/etherpad/p/yourpads )
 
Upvote
0 (0 / 0)

Zach1812

Seniorius Lurkius
8
Hello all,

I am again having a weird issue that pops up a 502 Bad Gateway when trying to access and run etherpad. Fortunately for me it's only affected etherpad and not the entire site this time. Here's a run of my /etc/nginx/sites-available/www file

Code:
server {
        listen 80 default_server;
        listen [::]:80 ipv6only=on default_server;

        root /usr/share/nginx/html;
        index index.html index.htm index.php;

        # Make site accessible from http://localhost/
        server_name mywebsitehere;

        include site-configs/wordpress.conf;
        include site-configs/vanilla.conf;
        include site-configs/wiki.conf;

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ /\. { access_log off; log_not_found off; deny all; }
        location ~ ~$ { access_log off; log_not_found off; deny all; }

        location ^~ /sqlbuddy/ {
                rewrite ^ https://$server_name$request_uri? permanent;
        }

        location /blog/ {
                try_files $uri $uri/ /blog/index.php?$args;
                # allow 192.168.1.1;
                # allow 127.0.0.1;
                # deny all;
        }

        location ~ /blog/.*\.php$ {
                # allow 192.168.1.1;
                # allow 127.0.0.1;
                # deny all;
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass php5-fpm-sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
        }

        location /vanilla/ {
                try_files $uri $uri/ @forum;
                # allow 192.168.1.1;
                # allow 127.0.0.1;
                # deny all;
        }

        location ~ /vanilla/.*\.php$ {
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass php5-fpm-sock;
                fastcgi_split_path_info ^(.+\.php)(.*)$;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
        }

        location @forum {
                rewrite ^/vanilla/(.+)$ /vanilla/index.php?p=$1 last;
        }

        location ~ /wiki/.*\.php5?$ {
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass php5-fpm-sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
        }

        location /etherpad {
                rewrite ^(.*) https://$server_name$1 permanent;
        }

}


server {
        listen 443 ssl;

        root /usr/share/nginx/html;
        index index.html index.htm index.php;

        server_name mywebsitehere;

        ssl on;
        ssl_certificate /etc/nginx/ssl/ssl-unified.crt;
        ssl_certificate_key /etc/nginx/ssl/ssl.key;
        ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM;
        ssl_prefer_server_ciphers on;
        ssl_ecdh_curve secp521r1;

        include site-configs/wordpress.conf;
        include site-configs/vanilla.conf;
        include site-configs/wiki.conf;

        location ~ /sqlbuddy/.*\.php$ {
                # allow 192.168.1.1;
                # allow 127.0.0.1;
                # deny all;
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass php5-fpm-sock;
                fastcgi_param HTTPS on;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
        }

        location /blog/ {
                try_files $uri $uri/ /blog/index.php?$args;
                # allow 192.168.1.1;
                # allow 127.0.0.1;
                # deny all;
        }

        location ~ /blog/.*.php$ {
                # allow 192.168.1.1;
                # allow 127.0.0.1;
                # deny all;
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass php5-fpm-sock;
                fastcgi_param HTTPS on;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
        }

        location /vanilla/ {
                try_files $uri $uri/ @forum;
                # allow 192.168.1.1;
                # allow 127.0.0.1;
                # deny all;
        }

        location ~ /vanilla/.*\.php$ {
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass php5-fpm-sock;
                fastcgi_split_path_info ^(.+\.php)(.*)$;
                fastcgi_param HTTPS on;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
        }

        location @forum {
                rewrite ^/vanilla/(.+)$ /vanilla/index.php?p=$1 last;
        }

        location ~ /wiki/.*\.php5?$ {
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass php5-fpm-sock;
                fastcgi_param HTTPS on;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
        }

        location /etherpad {
                proxy_pass https://localhost:9001/;
                proxy_set_header Host $host;
                proxy_buffering off;
        }

}

Here is my code for /etc/init/etherpad-lite.conf

Code:
description "etherpad-lite"
start on started networking
stop on runlevel [!2345]
env EPHOME=/usr/share/nginx/etherpad-lite
env EPLOGS=/var/log/etherpad-lite
env EPUSER=etherpadlite
respawn
pre-start script
chdir $EPHOME
        mkdir $EPLOGS                           ||true
        chown $EPUSER:admin $EPLOGS             ||true
        chmod 0755 $EPLOGS                      ||true
        chown -R $EPUSER:admin $EPHOME/var      ||true
$EPHOME/bin/installDeps.sh >> $EPLOGS/error.log || { stop; exit 1; }
end script
script
        cd $EPHOME/
        exec su -s /bin/sh -c 'exec "$0" "$@"' $EPUSER -- node node_modules/ep_etherpad-lite/node/server.js \
        >> $EPLOGS/access.log \
        2>> $EPLOGS/error.log
end script

Finally, here is my /usr/share/nginx/etherpad-lite/settings.json file

Code:
/*
  This file must be valid JSON. But comments are allowed

  Please edit settings.json, not settings.json.template
*/
{
  // Name your instance!
  "title": "PlayRPG Etherpad",

  // favicon default name
  // alternatively, set up a fully specified Url to your own favicon
  "favicon": "favicon.ico",

  //IP and port which etherpad should bind at
  "ip": "0.0.0.0",
  "port" : 9001,

  // Session Key, used for reconnecting user sessions
  // Set this to a secure string at least 10 characters long.  Do not share this value.
  "sessionKey" : "",

  /*  
  // Node native SSL support
  // this is disabled by default
  //
  // make sure to have the minimum and correct file access permissions set
  // so that the Etherpad server can access them

  "ssl" : {
            "key"  : "/path-to-your/epl-server.key",
            "cert" : "/path-to-your/epl-server.crt"
          },

  */

  //The Type of the database. You can choose between dirty, postgres, sqlite and mysql
  //You shouldn't use "dirty" for for anything else than testing or development
 // "dbType" : "dirty",
  //the database specific settings
 // "dbSettings" : {
 //                  "filename" : "var/dirty.db"
  //               },

  // An Example of MySQL Configuration
   "dbType" : "redis",
   "dbSettings" : {
                    "host"    : "localhost",
                    "port"    :  6379,
                   "database" :  0
                  },
  //the default text of a pad
  "defaultPadText" : "Welcome to Etherpad!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nGet involved with Etherpad at http:\/\/etherpad.org\n",

  /* Users must have a session to access pads. This effectively allows only group pads to be accessed. */
  "requireSession" : false,

  /* Users may edit pads but not create new ones. Pad creation is only via the API. This applies both to group pads and regular pads. */
  "editOnly" : false,

  /* if true, all css & js will be minified before sending to the client. This will improve the loading performance massivly, 
     but makes it impossible to debug the javascript/css */
  "minify" : true,

  /* How long may clients use served javascript code (in seconds)? Without versioning this
     may cause problems during deployment. Set to 0 to disable caching */
  "maxAge" : 21600, // 60 * 60 * 6 = 6 hours

  /* This is the path to the Abiword executable. Setting it to null, disables abiword.
     Abiword is needed to advanced import/export features of pads*/
  "abiword" : null,

  /* This setting is used if you require authentication of all users.
     Note: /admin always requires authentication. */
  "requireAuthentication": false,

  /* Require authorization by a module, or a user with is_admin set, see below. */
  "requireAuthorization": false,

  /*when you use NginX or another proxy/ load-balancer set this to true*/
  "trustProxy": false,

  /* Privacy: disable IP logging */
  "disableIPlogging": false,

  /* Users for basic authentication. is_admin = true gives access to /admin.
     If you do not uncomment this, /admin will not be available! */
  /*
  "users": {
    "admin": {
      "password": "changeme1",
      "is_admin": true
    },
    "user": {
      "password": "changeme1",
      "is_admin": false
    }
  },
  */

  // restrict socket.io transport methods
  "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"],

  /* The toolbar buttons configuration.
  "toolbar": {
    "left": [
      ["bold", "italic", "underline", "strikethrough"],
      ["orderedlist", "unorderedlist", "indent", "outdent"],
      ["undo", "redo"],
      ["clearauthorship"]
    ],
    "right": [
      ["importexport", "timeslider", "savedrevision"],
      ["settings", "embed"],
      ["showusers"]
    ]
  },
  */

  /* The log level we are using, can be: DEBUG, INFO, WARN, ERROR */
  "loglevel": "INFO",

  //Logging configuration. See log4js documentation for further information
  // https://github.com/nomiddlename/log4js-node
  // You can add as many appenders as you want here:
  "logconfig" :
    { "appenders": [
        { "type": "console"
        //, "category": "access"// only logs pad access
        }
    /*
      , { "type": "file"
      , "filename": "your-log-file-here.log"
      , "maxLogSize": 1024
      , "backups": 3 // how many log files there're gonna be at max
      //, "category": "test" // only log a specific category
        }*/
    /*
      , { "type": "logLevelFilter"
        , "level": "warn" // filters out all log messages that have a lower level than "error"
        , "appender":
          {  Use whatever appender you want here  }
        }*/
    /*
      , { "type": "logLevelFilter"
        , "level": "error" // filters out all log messages that have a lower level than "error"
        , "appender":
          { "type": "smtp"
          , "subject": "An error occured in your EPL instance!"
          , "recipients": "bar@blurdybloop.com, baz@blurdybloop.com"
          , "sendInterval": 60*5 // in secs -- will buffer log messages; set to 0 to send a mail for every message
          , "transport": "SMTP", "SMTP": { // see https://github.com/andris9/Nodemailer#possible-transport-methods
              "host": "smtp.example.com", "port": 465,
              "secureConnection": true,
              "auth": {
                  "user": "foo@example.com",
                  "pass": "bar_foo"
              }
            }
          }
        }*/
      ]
    }
}

Thanks in advance to help given! :)
 
Upvote
0 (0 / 0)
[url=http://meincmagazine.com/civis/viewtopic.php?p=25678777#p25678777:3echpjm3 said:
acorbo[/url]":3echpjm3]
[url=http://meincmagazine.com/civis/viewtopic.php?p=25044279#p25044279:3echpjm3 said:
Collie147[/url]":3echpjm3]change it to
"location ~* /wiki/\*.(js|css|png|jpg|jpeg|gif|ico)$" and it seems to have worked.


I had the exact same behavior on my installation. I tried your changes and it appears to be working now. Still, I'm at a loss on 'why' would a wiki location have any effect on the pad's css... Let me know the reason if you have the time, and thanks a million for posting it...

I'm also in the same boat. I'm able to fix up etherpad with this fix but then the wiki loses images. Thanks for the fantastic series by the way. Had it saved a long time ago and recently had some time and came across my old links.
 
Upvote
0 (0 / 0)

acorbo

Seniorius Lurkius
11
Hi Lee,

On this post you show how to setup a location for etherpad as follows:

location /etherpad {
rewrite /etherpad/(.*) /$1 break;
rewrite ^/etherpad$ /etherpad/ permanent;
proxy_pass http://localhost:9001/;
proxy_redirect / /etherpad/;
proxy_set_header Host $host;
proxy_buffering off;
}

This triggered an idea I've been wondering about for a few days, but haven't found the right steps of instructions to come up with a viable solution.

How would you set up nginx as a reverse proxy for an apache web server I'm running on a Mac Mini Server as well as a web server for all the applications you've covered here? Do I need two instances of nginx or just a new location with the proxy_pass command? I'm at an impasse with the basic concept and the specific commands. Thanks.
--a
 
Upvote
0 (0 / 0)

acerskine

Seniorius Lurkius
1
Zach,

I'm having this same issue. Did you ever get it resolved?



[url=http://meincmagazine.com/civis/viewtopic.php?p=26508769#p26508769:of0fca2l said:
Zach1812[/url]":eek:f0fca2l]Hello all,

I am again having a weird issue that pops up a 502 Bad Gateway when trying to access and run etherpad. Fortunately for me it's only affected etherpad and not the entire site this time. Here's a run of my /etc/nginx/sites-available/www file

Code:
server {
        listen 80 default_server;
        listen [::]:80 ipv6only=on default_server;

        root /usr/share/nginx/html;
        index index.html index.htm index.php;

        # Make site accessible from http://localhost/
        server_name mywebsitehere;

        include site-configs/wordpress.conf;
        include site-configs/vanilla.conf;
        include site-configs/wiki.conf;

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ /\. { access_log off; log_not_found off; deny all; }
        location ~ ~$ { access_log off; log_not_found off; deny all; }

        location ^~ /sqlbuddy/ {
                rewrite ^ https://$server_name$request_uri? permanent;
        }

        location /blog/ {
                try_files $uri $uri/ /blog/index.php?$args;
                # allow 192.168.1.1;
                # allow 127.0.0.1;
                # deny all;
        }

        location ~ /blog/.*\.php$ {
                # allow 192.168.1.1;
                # allow 127.0.0.1;
                # deny all;
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass php5-fpm-sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
        }

        location /vanilla/ {
                try_files $uri $uri/ @forum;
                # allow 192.168.1.1;
                # allow 127.0.0.1;
                # deny all;
        }

        location ~ /vanilla/.*\.php$ {
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass php5-fpm-sock;
                fastcgi_split_path_info ^(.+\.php)(.*)$;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
        }

        location @forum {
                rewrite ^/vanilla/(.+)$ /vanilla/index.php?p=$1 last;
        }

        location ~ /wiki/.*\.php5?$ {
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass php5-fpm-sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
        }

        location /etherpad {
                rewrite ^(.*) https://$server_name$1 permanent;
        }

}


server {
        listen 443 ssl;

        root /usr/share/nginx/html;
        index index.html index.htm index.php;

        server_name mywebsitehere;

        ssl on;
        ssl_certificate /etc/nginx/ssl/ssl-unified.crt;
        ssl_certificate_key /etc/nginx/ssl/ssl.key;
        ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM;
        ssl_prefer_server_ciphers on;
        ssl_ecdh_curve secp521r1;

        include site-configs/wordpress.conf;
        include site-configs/vanilla.conf;
        include site-configs/wiki.conf;

        location ~ /sqlbuddy/.*\.php$ {
                # allow 192.168.1.1;
                # allow 127.0.0.1;
                # deny all;
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass php5-fpm-sock;
                fastcgi_param HTTPS on;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
        }

        location /blog/ {
                try_files $uri $uri/ /blog/index.php?$args;
                # allow 192.168.1.1;
                # allow 127.0.0.1;
                # deny all;
        }

        location ~ /blog/.*.php$ {
                # allow 192.168.1.1;
                # allow 127.0.0.1;
                # deny all;
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass php5-fpm-sock;
                fastcgi_param HTTPS on;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
        }

        location /vanilla/ {
                try_files $uri $uri/ @forum;
                # allow 192.168.1.1;
                # allow 127.0.0.1;
                # deny all;
        }

        location ~ /vanilla/.*\.php$ {
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass php5-fpm-sock;
                fastcgi_split_path_info ^(.+\.php)(.*)$;
                fastcgi_param HTTPS on;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
        }

        location @forum {
                rewrite ^/vanilla/(.+)$ /vanilla/index.php?p=$1 last;
        }

        location ~ /wiki/.*\.php5?$ {
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass php5-fpm-sock;
                fastcgi_param HTTPS on;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
        }

        location /etherpad {
                proxy_pass https://localhost:9001/;
                proxy_set_header Host $host;
                proxy_buffering off;
        }

}

Here is my code for /etc/init/etherpad-lite.conf

Code:
description "etherpad-lite"
start on started networking
stop on runlevel [!2345]
env EPHOME=/usr/share/nginx/etherpad-lite
env EPLOGS=/var/log/etherpad-lite
env EPUSER=etherpadlite
respawn
pre-start script
chdir $EPHOME
        mkdir $EPLOGS                           ||true
        chown $EPUSER:admin $EPLOGS             ||true
        chmod 0755 $EPLOGS                      ||true
        chown -R $EPUSER:admin $EPHOME/var      ||true
$EPHOME/bin/installDeps.sh >> $EPLOGS/error.log || { stop; exit 1; }
end script
script
        cd $EPHOME/
        exec su -s /bin/sh -c 'exec "$0" "$@"' $EPUSER -- node node_modules/ep_etherpad-lite/node/server.js \
        >> $EPLOGS/access.log \
        2>> $EPLOGS/error.log
end script

Finally, here is my /usr/share/nginx/etherpad-lite/settings.json file

Code:
/*
  This file must be valid JSON. But comments are allowed

  Please edit settings.json, not settings.json.template
*/
{
  // Name your instance!
  "title": "PlayRPG Etherpad",

  // favicon default name
  // alternatively, set up a fully specified Url to your own favicon
  "favicon": "favicon.ico",

  //IP and port which etherpad should bind at
  "ip": "0.0.0.0",
  "port" : 9001,

  // Session Key, used for reconnecting user sessions
  // Set this to a secure string at least 10 characters long.  Do not share this value.
  "sessionKey" : "",

  /*  
  // Node native SSL support
  // this is disabled by default
  //
  // make sure to have the minimum and correct file access permissions set
  // so that the Etherpad server can access them

  "ssl" : {
            "key"  : "/path-to-your/epl-server.key",
            "cert" : "/path-to-your/epl-server.crt"
          },

  */

  //The Type of the database. You can choose between dirty, postgres, sqlite and mysql
  //You shouldn't use "dirty" for for anything else than testing or development
 // "dbType" : "dirty",
  //the database specific settings
 // "dbSettings" : {
 //                  "filename" : "var/dirty.db"
  //               },

  // An Example of MySQL Configuration
   "dbType" : "redis",
   "dbSettings" : {
                    "host"    : "localhost",
                    "port"    :  6379,
                   "database" :  0
                  },
  //the default text of a pad
  "defaultPadText" : "Welcome to Etherpad!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nGet involved with Etherpad at http:\/\/etherpad.org\n",

  /* Users must have a session to access pads. This effectively allows only group pads to be accessed. */
  "requireSession" : false,

  /* Users may edit pads but not create new ones. Pad creation is only via the API. This applies both to group pads and regular pads. */
  "editOnly" : false,

  /* if true, all css & js will be minified before sending to the client. This will improve the loading performance massivly, 
     but makes it impossible to debug the javascript/css */
  "minify" : true,

  /* How long may clients use served javascript code (in seconds)? Without versioning this
     may cause problems during deployment. Set to 0 to disable caching */
  "maxAge" : 21600, // 60 * 60 * 6 = 6 hours

  /* This is the path to the Abiword executable. Setting it to null, disables abiword.
     Abiword is needed to advanced import/export features of pads*/
  "abiword" : null,

  /* This setting is used if you require authentication of all users.
     Note: /admin always requires authentication. */
  "requireAuthentication": false,

  /* Require authorization by a module, or a user with is_admin set, see below. */
  "requireAuthorization": false,

  /*when you use NginX or another proxy/ load-balancer set this to true*/
  "trustProxy": false,

  /* Privacy: disable IP logging */
  "disableIPlogging": false,

  /* Users for basic authentication. is_admin = true gives access to /admin.
     If you do not uncomment this, /admin will not be available! */
  /*
  "users": {
    "admin": {
      "password": "changeme1",
      "is_admin": true
    },
    "user": {
      "password": "changeme1",
      "is_admin": false
    }
  },
  */

  // restrict socket.io transport methods
  "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"],

  /* The toolbar buttons configuration.
  "toolbar": {
    "left": [
      ["bold", "italic", "underline", "strikethrough"],
      ["orderedlist", "unorderedlist", "indent", "outdent"],
      ["undo", "redo"],
      ["clearauthorship"]
    ],
    "right": [
      ["importexport", "timeslider", "savedrevision"],
      ["settings", "embed"],
      ["showusers"]
    ]
  },
  */

  /* The log level we are using, can be: DEBUG, INFO, WARN, ERROR */
  "loglevel": "INFO",

  //Logging configuration. See log4js documentation for further information
  // https://github.com/nomiddlename/log4js-node
  // You can add as many appenders as you want here:
  "logconfig" :
    { "appenders": [
        { "type": "console"
        //, "category": "access"// only logs pad access
        }
    /*
      , { "type": "file"
      , "filename": "your-log-file-here.log"
      , "maxLogSize": 1024
      , "backups": 3 // how many log files there're gonna be at max
      //, "category": "test" // only log a specific category
        }*/
    /*
      , { "type": "logLevelFilter"
        , "level": "warn" // filters out all log messages that have a lower level than "error"
        , "appender":
          {  Use whatever appender you want here  }
        }*/
    /*
      , { "type": "logLevelFilter"
        , "level": "error" // filters out all log messages that have a lower level than "error"
        , "appender":
          { "type": "smtp"
          , "subject": "An error occured in your EPL instance!"
          , "recipients": "bar@blurdybloop.com, baz@blurdybloop.com"
          , "sendInterval": 60*5 // in secs -- will buffer log messages; set to 0 to send a mail for every message
          , "transport": "SMTP", "SMTP": { // see https://github.com/andris9/Nodemailer#possible-transport-methods
              "host": "smtp.example.com", "port": 465,
              "secureConnection": true,
              "auth": {
                  "user": "foo@example.com",
                  "pass": "bar_foo"
              }
            }
          }
        }*/
      ]
    }
}

Thanks in advance to help given! :)
 
Upvote
0 (0 / 0)
Status
Not open for further replies.