Updated README and added nginx sample configuration file

This commit is contained in:
Pitu 2017-10-04 02:26:00 -03:00
parent 992b632d1a
commit 5ff33ba930
2 changed files with 65 additions and 30 deletions

View File

@ -1,41 +1,20 @@
![loli-safe](https://a.safe.moe/jcutlz.png)
![loli-safe](https://a.safe.moe/jcutlz.png)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://raw.githubusercontent.com/kanadeko/Kuro/master/LICENSE)
[![Chat / Support](https://img.shields.io/badge/Chat%20%2F%20Support-discord-7289DA.svg?style=flat-square)](https://discord.gg/5g6vgwn)
# lolisafe, a small safe worth protecting.
## Sites using loli-safe
- [lolisafe.moe](https://lolisafe.moe): A small safe worth protecting.
- [safe.moe](https://safe.moe): The world most ~~un~~safe pomf clone
- Feel free to add yours here.
## What's new in v3.0.0
- Backend rewrite to make it faster, better and easier to extend
- Album downloads (Thanks to [PascalTemel](https://github.com/PascalTemel))
- See releases for changelog
## What's new in v2.2.0
- Creation of public link for sharing a gallery
- Ability to add your own html files without making git dirty (Check [this commit](https://github.com/WeebDev/loli-safe/commit/18c66d27fb580ed0f847f11525d2d2dca0fda2f4))
- Thumbnail creation for .webm and .mp4 (Thanks to [PascalTemel](https://github.com/PascalTemel))
- Changed how duplicate files work (Check [this issue for more info](https://github.com/WeebDev/loli-safe/issues/8))
If you're upgrading from a previous version, create a `migrate.js` file on the root folder with the following code and run it only once:
```js
const config = require('./config.js')
const db = require('knex')(config.database)
const randomstring = require('randomstring')
db.schema.table('albums', function (table) {
table.string('identifier')
}).then(() => {
db.table('albums').then((albums) => {
for(let album of albums)
db.table('albums').where('id', album.id).update('identifier', randomstring.generate(8)).then(() => {})
})
})
```
If you're upgrading from a version prior to v3.0.0 make sure to run **ONCE** `node database/migration.js` to create the missing columns on the database.
## Running
1. Clone
2. Rename `config.sample.js` to `config.js`
4. Modify port, basedomain and privacy options if desired
4. Modify port, domain and privacy options if desired
3. run `npm install` to install all dependencies
5. run `pm2 start lolisafe.js` or `node lolisafe.js` to start the service
@ -44,6 +23,17 @@ This service supports running both as public and private. The only difference is
Upon running the service for the first time, it's gonna create a user account with the username `root` and password `root`. This is your admin account and you should change the password immediately. This account will let you manage all uploaded files and remove any if necessary.
The option `serveFilesWithNode` in the `config.js` dictates if you want lolisafe to serve the files or nginx/apache once they are uploaded. The main difference between the two is the ease of use and the chance of analytics in the future.
If you set it to `true`, the uploaded files will be located after the host like:
https://lolisafe.moe/yourFile.jpg
If you set it to `false`, you need to set nginx to directly serve whatever folder it is you are serving your
downloads in. This also gives you the ability to serve them, for example, like this:
https://files.lolisafe.moe/yourFile.jpg
Both cases require you to type the domain where the files will be served on the `domain` key below.
Which one you use is ultimately up to you. Either way, I've provided a [sample config file for nginx](https://github.com/WeebDev/lolisafe/blob/master/nginx.sample.conf) that you can use to set it up quickly and painlessly!
If you set `enableUserAccounts: true`, people will be able to create accounts on the service to keep track of their uploaded files and create albums to upload stuff to, pretty much like imgur does, but only through the API. Every user account has a token that the user can use to upload stuff through the API. You can find this token on the section called `Change your token` on the administration dashboard, and if it gets leaked or compromised you can renew it by clicking the button titled `Request new token`.
## Using loli-safe
@ -62,8 +52,10 @@ To make it easier and better than any other service, you can download [our Chrom
Because of how nodejs apps work, if you want it attached to a domain name you will need to make a reverse proxy for it. Here is a tutorial [on how to do this with nginx](https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04). Keep in mind that this is only a requirement if you want to access your loli-safe service by using a domain name (ex: https://i.kanacchi.moe), otherwise you can use the service just fine by accessing it from your server's IP.
If you choose to use a domain name and thus nginx, you should add the following directive into your location block with the limit you want to set on uploaded file's size:
`client_max_body_size 512M;`
## Sites using loli-safe
- [lolisafe.moe](https://lolisafe.moe): A small safe worth protecting.
- [safe.moe](https://safe.moe): The world's most ~~un~~safe pomf clone
- Feel free to add yours here.
## Author

43
nginx.sample.conf Normal file
View File

@ -0,0 +1,43 @@
upstream backend {
server 127.0.0.1:3000; # Change to the port you specified on lolisafe
}
server {
listen 80;
listen [::]:80;
server_name lolisafe.moe;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name lolisafe.moe;
ssl_certificate /path/to/your/fullchain.pem;
ssl_certificate_key /path/to/your/privkey.pem;
ssl_trusted_certificate /path/to/your/fullchain.pem;
client_max_body_size 100M; # Change this to the max file size you want to allow
location / {
add_header Access-Control-Allow-Origin *;
root /path/to/your/uploads/folder;
try_files $uri @proxy;
}
location @proxy {
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://backend;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
}
}