jschan - Anonymous imageboard software. Classic look, modern features and feel. Works without JavaScript and supports Tor, I2P, Lokinet, etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

171 lines
7.2 KiB

5 years ago
# jschan
4 years ago
Anonymous imageboard software.
4 years ago
5 years ago
## Goals
- Oldschool look, newschool features
4 years ago
- Work with javascript disabled
- Support running as a hidden service
4 years ago
- Be usable on mobile
- Simple static file serving
5 years ago
## Features
- [x] User created boards ala infinity
- [x] Multiple files per post
- [x] Basic antispam & multiple captcha options
- [x] Read-only JSON api
- [x] Multi-select moderation actions
- [x] Websocket update threads w/o polling
- [x] Webring w/proxy support (compatible with [lynxchan](https://gitlab.com/alogware/LynxChanAddon-Webring) & [infinity](https://gitlab.com/Tenicu/infinityaddon-webring))
- [x] Run as a tor hidden service ([demo](http://http://qga4iyo7rp3kjhwvbkdo6vxeuo4r2suq4fygkwbsw7hve7cykwgrdpyd.onion))
5 years ago
## Todo
4 years ago
- More features
- Mobile app integration
- Improve installation instructions
5 years ago
## Setup
##### Please note:
#### 🚨 jschan is not production-ready. There may be bugs and WILL be breaking changes. 🚨
##### If you insist on running your own instance, do not expect help when something breaks. Please read everything including the update section thoroughly. These instructions are NOT step-by-step or complete, and assume you have some experience with software setup, servers, networking, etc.
5 years ago
##### Requirements
- Linux - Debian used in this example
4 years ago
- Node.js - the application runtime
- MongoDB - the database
- Redis - session store, task queue, locks, caching, websocket message arbiter
- Nginx - webserver/proxy, serve static files, handle https, GeoIP lookup
- Certbot/letsencrypt - to get a free https certificate
- Graphicsmagick+Imagemagick - identify and thumbnail images, generate captchas
- Ffmpeg - identify and thumbnail audio and video
-----
**1. Setup server with some basics**
- Separate, non-root user to run the application
- Basic security like ssh root login disabled, key login only, firewall all ports besides http/s and ssh.
**2. Install dependencies.**
NOTE: You may need to add sources depending on your distro.
5 years ago
```bash
$ sudo apt-get update
$ sudo apt-get install nginx ffmpeg imagemagick graphicsmagick
5 years ago
```
**3. Install MongoDB**
[MongoDB Installation](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/#install-mongodb-community-edition-on-debian) & [enable authentication](https://medium.com/mongoaudit/how-to-enable-authentication-on-mongodb-b9e8a924efac)
5 years ago
**4. Install Redis**
[Redis Installation](https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-debian-9)
**5. Install Node.js**
For easy installation, use [node version manager](https://github.com/nvm-sh/nvm) "nvm".
4 years ago
Install nvm then run the following commands to get the LTS version of nodejs.
5 years ago
```bash
$ nvm install --lts
4 years ago
$ nvm use --lts
5 years ago
```
You can repeat this process in future to update node versions.
You may install Node.js yourself without nvm if you prefer.
5 years ago
**6. Configure nginx**
- Copy the nginx.example config to the sites-eavailable folder, and create a symlink from sites-available -> sites-enabled
```bash
$ sudo cp configs/nginx/nginx.example /etc/nginx/sites-available/DOMAIN.COM
$ sudo ln -s /etc/nginx/sites-available/DOMAIN.COM /etc/nginx/sites-enabled/DOMAIN.COM
```
Edit/replace the following in your nginx config:
- "domain.com" with your domain name
- "/path/to/jschan" with the path of your jschan root folder
- If using .onion, uncomment the .onion block, and replace the example address with your .onion
```bash
$ sudo editor /etc/nginx/sites-available/DOMAIN.COM
```
- Make sure the sites enabled folder is included by `/etc/nginx/nginx.conf` (it is in debian nginx package)
- Use [certbot](https://certbot.eff.org/) to get a free https certificate.
- For post flags to work, [follow this guide](http://archive.is/2SMOb) to setup the [legacy GeoIP database](https://www.miyuru.lk/geoiplegacy) and add these directives to the http block in `/etc/nginx/nginx.conf`:
```
geoip_country /usr/share/GeoIP/GeoIP.dat;
geoip_city /usr/share/GeoIP/GeoIPCity.dat;
```
If your nginx doesn't have the necessary module by default, or is using v2 instead, find your own guide.
If you use cloudflare, please read [these](https://support.cloudflare.com/hc/en-us/articles/200170786-Restoring-original-visitor-IPs-Logging-visitor-IP-addresses-with-mod-cloudflare-) [articles](https://support.cloudflare.com/hc/en-us/articles/200168236-Configuring-Cloudflare-IP-Geolocation) to setup proper IP forwarding and geolocation headers. Similar steps would apply to other CDNs/reverse proxies.
There are also 2 config entries in configs/main.js, `ipHeader` and `countryCodeHeader` that you can tweak for jschan to use different headers for country code or real visitor IP.
Also included is an "nginx_advanced" config, and a snippets folder for advanced users who want to better organise and more easily customise the nginx configuration. It functions the same as the normal nginx.example, but you need to create the snippets folder in /etc/nginx/snippets, and copy the example snippets.
**7. Clone this repo, browse to the folder and set some things up**
5 years ago
```bash
# copy example config file and edit it
4 years ago
$ cp configs/main.js.example configs/main.js && editor configs/main.js
# copy example custompages for rules and faq and edit
$ cp views/custompages/faq.pug.example views/custompages/faq.pug
$ cp views/custompages/rules.pug.example views/custompages/rules.pug
4 years ago
# install dependencies and run build tasks
$ npm install
4 years ago
$ npm run-script setup
# setup the database and folder structure, and creates the admin account. **The (random) password will be printed in the command line.**
$ gulp reset
# NOTE: dont run gulp reset again unless you want to completely irreversibly wipe everything
4 years ago
```
4 years ago
Use https://realfavicongenerator.net/ to generate favicons how you want them to look and replace the files in gulp/res/icons/ with the icons from that package
4 years ago
4 years ago
```bash
4 years ago
# start all the backend processes
$ npm run-script start
4 years ago
$ gulp
4 years ago
# some commands you may need to use in future/find helpful
# pm2 is a process manager for nodejs
$ pm2 list #list running pm2 processes
5 years ago
$ pm2 logs #see logs
4 years ago
$ pm2 reload all #reload all backend processes
4 years ago
# gulp is used for various jobs like minifying and compiling scripts
$ gulp --tasks #list available gulp tasks
$ gulp migrate #check for and run db migrations
4 years ago
$ gulp #run default gulp task
5 years ago
```
**8. Optionally, if you plan to use the webring and want to make requests with a proxy to mask your origin server IP:**
EITHER:
- Install docker and run torproxy in a container: https://github.com/dperson/torproxy (of course, audit the docker image yourself)
- Use your own socks proxy
Edit configs/webring.json with your proxy address and set enabled: true
## Updating
```bash
#pull the latest changes
$ git pull
#install dependencies again in case any have updated or changed
$ npm install
#diff the config files to see if anything changed and edit accordingly. OR backup your config, replace it with the fresh example, and update it with whatever settings you want to keep from your backup.
$ diff configs/main.js configs/main.js.example
#run the migrate task to update your database
$ gulp migrate
#reload jschan backend
$ pm2 reload all
#run the default gulp task, updates scripts, css, icons, images and deletes old html
$ gulp
#if something breaks, check and read the logs, they will help figure out what went wrong.
$ pm2 logs
```