NodeJS rewrite of nokonoko/Pomf.
For the purposes of this guide, we won't cover setting up Nginx, Node, or NPM. So we'll just assume you already have them all running well.
Assuming you already have Node and NPM working, setting up npomf is easy:
$ git clone https://github.com/maxpowa/npomf.git
$ cd npomf
$ npm install
That's it. You can now run the app with npm start
docker pull maxpowa/npomf
Start the container as you would normally.
In the config folder, you will find all of the files that effect the operation of the application. Most config options should be self-explanatory or will have extensive documentation on them.
For configuring in docker, you can specify environment variables to overwrite the existing config by adding NPOMF_<CONFIG_VALUE> to your env. You can also create a volume over the config file with
-v <path/to/your/core.js>:/usr/src/app/config/core.js
Usually, you want to run a NodeJS app behind a proxy like nginx. Configuring nginx with npomf is easy.
# Point the 'server' option here to your npomf instance
upstream npomf {
server 127.0.0.1:3000;
keepalive 128;
}
# This defines the vhost, configure based on your setup
server {
listen 80;
server_name my.public.server;
location / {
proxy_pass http://npomf/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
}
}
For SSL support, add another server block after the previous one containing the following.
server {
listen 443;
server_name my.public.server;
# If you're worried about SSL you should know to point the
# 'ssl_certificate' and 'ssl_certificate_key' to your own
# locations
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
location / {
proxy_pass http://npomf/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
}
}
If you want nginx to handle serving uploaded files, simply add a location block pointing to the configured files directory. This is not required, as NPomf handlers serving files on its own by default.
In the nginx main config, you'll have to change the client_max_body_size
in
order to allow uploads larger than 1MB. You should change it to whatever you
choose as the max upload size in the config file.
http {
...
client_max_body_size 100m;
...
}