mirror of
https://codeberg.org/tacerus/teddit.git
synced 2024-11-21 14:29:28 +01:00
simplify installation
This commit is contained in:
parent
3814a67517
commit
ce6c306b3a
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
node_modules/
|
||||
*.log
|
||||
config.js
|
||||
|
104
README.md
104
README.md
@ -46,95 +46,27 @@ Community instances:
|
||||
* User login, so people can use their Reddit account through teddit to comment and up/downvote posts etc.
|
||||
|
||||
## Installation
|
||||
This is a quick guide how to run teddit on your own server. Tested on fresh install of Debian 10. You can install teddit also locally without certificates and so on, but there's no guide for it (not yet).
|
||||
|
||||
Run as root:
|
||||
|
||||
`# apt update && apt upgrade`
|
||||
|
||||
`# curl -sL https://deb.nodesource.com/setup_14.x | bash -`
|
||||
|
||||
`# apt install -y nodejs redis-server ffmpeg git curl certbot` *leave ffmpeg out if you don't want video support*
|
||||
|
||||
`# adduser teddit`
|
||||
|
||||
`# mkdir -p /home/teddit/letsencrypt/ /home/teddit/letsencrypt/logs/ /home/teddit/letsencrypt/lib/`
|
||||
|
||||
`# chown teddit:teddit -R /home/teddit/letsencrypt/`
|
||||
|
||||
`# iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080` *route port 8080 to 80*
|
||||
|
||||
`# iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8088` *route port 8088 to 443*
|
||||
|
||||
`# apt install iptables-persistent` *save iptables configuration to be persistent*
|
||||
|
||||
Edit redis.conf file and set **maxmemory** value suitable for your server (e.g. 75% of your total RAM):
|
||||
|
||||
1. Install [node.js](https://nodejs.org/en/)
|
||||
For example:
|
||||
`# curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs`
|
||||
1. Install [redis-server](https://redis.io/) and [ffmpeg](https://ffmpeg.org/)
|
||||
For example:
|
||||
`# apt install redis-server ffmpeg`
|
||||
Leave ffmpeg out if you don't want video support.
|
||||
1. `$ git clone https://codeberg.org/teddit/teddit`
|
||||
1. `$ cd teddit`
|
||||
1. `$ npm install --no-optional`
|
||||
1. Edit `config.js.template` to suit your environment. After done, rename it to config.js.
|
||||
1. Edit redis.conf file and set maxmemory value to suit your environment (e.g. 75% of your total RAM).
|
||||
`# nano /etc/redis/redis.conf`
|
||||
|
||||
Add this to the end of the file:
|
||||
|
||||
Add new lines:
|
||||
`maxmemory 2gb`
|
||||
|
||||
Also add maxmemory-policy:
|
||||
|
||||
`maxmemory-policy volatile-ttl`
|
||||
|
||||
Save and exit.
|
||||
1. Restart redis
|
||||
For example:
|
||||
`systemctl restart redis`
|
||||
1. `$ node app.js`
|
||||
|
||||
Restart redis:
|
||||
|
||||
`# systemctl restart redis`
|
||||
|
||||
Let's log in for teddit user.
|
||||
|
||||
`# su - teddit`
|
||||
|
||||
`$ git clone https://codeberg.org/teddit/teddit`
|
||||
|
||||
`$ cd teddit`
|
||||
|
||||
`$ npm install && npm update`
|
||||
|
||||
Let's obtain certificates. Run HTTP server:
|
||||
|
||||
`$ nohup node setup_server.js </dev/null &>/dev/null &`
|
||||
|
||||
Then run certbot. Change "teddit.net" to your domain, and also change the "ADD_YOUR_EMAIL_ADDRESS@SOMETHING.ORG" email.
|
||||
|
||||
`$ certbot certonly --webroot -w /home/teddit/teddit/dist/ -d teddit.net --agree-tos --no-eff-email --manual-public-ip-logging-ok --config-dir /home/teddit/letsencrypt/ --logs-dir /home/teddit/letsencrypt/logs/ --work-dir /home/teddit/letsencrypt/lib/ --email ADD_YOUR_EMAIL_ADDRESS@SOMETHING.ORG`
|
||||
|
||||
Kill the node HTTP server:
|
||||
|
||||
`$ ps aux | grep node`
|
||||
|
||||
`$ kill -9 [PID HERE]`
|
||||
|
||||
Change config variables in app.js for domain and Reddit app ID. Note: It's recommended that you get your own Reddit app ID. For testing purposes it's okay to use this project's default app ID. Create your Reddit app here: [https://old.reddit.com/prefs/apps/](https://old.reddit.com/prefs/apps/). Make sure to create an "installed app" type of app.
|
||||
|
||||
`$ nano app.js`
|
||||
|
||||
Save and exit.
|
||||
|
||||
Now let's start teddit:
|
||||
|
||||
`$ nohup node app.js > output.log &`
|
||||
|
||||
If everything went okay, you should have teddit instance running on your domain with a valid SSL certificate.
|
||||
Tailing output.log:
|
||||
|
||||
`$ tail -f output.log`
|
||||
|
||||
You should see something like:
|
||||
|
||||
```
|
||||
Teddit running on https://teddit.net
|
||||
Teddit running on http://teddit.net
|
||||
Successfully obtained a reddit API key.
|
||||
```
|
||||
|
||||
|
||||
### Other
|
||||
|
||||
* Using nohup for starting and killing the node process might be a bit of a hassle, but this project aims to be as minimalistic as possible. If you want to use process managers like [pm2](https://www.npmjs.com/package/pm2) it's perfectly fine.
|
||||
* Teddit doesn't have any fancy logging built in. There's no IP address or even timestamp logging.
|
||||
Teddit should be now running.
|
||||
|
35
config.js.template
Normal file
35
config.js.template
Normal file
@ -0,0 +1,35 @@
|
||||
const config = {
|
||||
domain: '127.0.0.1', // Or for example 'teddit.net'
|
||||
reddit_app_id: 'H6-HjZ5pUPjaFQ', // You should obtain your own Reddit app ID
|
||||
cert_dir: '', // For example '/home/teddit/letsencrypt/live/teddit.net', if you are using https. No trailing slash.
|
||||
video_enabled: true,
|
||||
ssl_port: 8088,
|
||||
nonssl_port: 8080,
|
||||
listen_address: '0.0.0.0',
|
||||
https_enabled: false,
|
||||
redirect_http_to_https: false,
|
||||
use_compression: true,
|
||||
use_view_cache: false,
|
||||
use_helmet: false, // Recommended to be true when using https
|
||||
use_helmet_hsts: false, // Recommended to be true when using https
|
||||
trust_proxy: false, // Enable trust_proxy if you are using reverse proxy like nginx
|
||||
trust_proxy_address: '127.0.0.1',
|
||||
setexs: {
|
||||
/**,
|
||||
* Redis cache expiration values (in seconds).
|
||||
* When the cache expires, new content is fetched from Reddit's API (when
|
||||
* the given URL is revisited).
|
||||
*/
|
||||
frontpage: 600,
|
||||
subreddit: 600,
|
||||
posts: 600,
|
||||
user: 600,
|
||||
searches: 600,
|
||||
sidebar: 60 * 60 * 24 * 7 // 7 days
|
||||
},
|
||||
post_comments_sort: 'confidence', // one of: confidence, top, new, controversial, old, random, qa, live
|
||||
valid_media_domains: ['preview.redd.it', 'external-preview.redd.it', 'i.redd.it', 'v.redd.it', 'a.thumbs.redditmedia.com', 'b.thumbs.redditmedia.com', 'thumbs.gfycat.com', 'i.ytimg.com'],
|
||||
reddit_api_error_text: `Seems like your instance is either blocked (e.g. due to API rate limiting), reddit is currently down, or your API key is expired and not renewd properly. This can also happen for other reasons.`
|
||||
};
|
||||
|
||||
module.exports = config;
|
Loading…
Reference in New Issue
Block a user