Unlocking Greater Reddit App Functionality with Custom Servers: A Guide on Integrating Third-Party Apps

How to Set Up a Custom Reddit Server for Third-Party Apps

The upcoming price increase for the Reddit API has resulted in the developers of many third-party Reddit apps announcing plans to shut down their apps on June 30. Many have encouraged these developers to update their apps to use a different server. Until 2017, the source code for Reddit and its API were open source, and this code is still available as an archive. In this article, we will show you how to set up a custom Reddit server and use it with unmodified third-party Reddit apps.

Setting Up the Server

The Reddit source code currently only runs on Ubuntu 14.04. While anyone who would want to host a public server should update/recompile dependencies to get it to run on a newer operating system, this is okay for the proof of concept. Ubuntu 14.04 will receive security updates until April 2024.

To begin, download and install VirtualBox and also download the Ubuntu 14.04.6 server image. (The desktop image will also work if you’d like a GUI.) Create a new VM. Select the ISO you downloaded, skip unattended installation, and give it at least 4096MB of memory. I would also recommend giving it multiple CPUs. The default hard disk size is fine.

Install the OS normally, but set your username to reddit. Select “Choose packages manually” at the end. Once in the system, login and install any security updates: sudo apt update && sudo apt upgrade -y.

Next, install Reddit using the script available in the repo with a minor environment variable tweak: wget chmod +x sudo ./ Press y when prompted.

Set up port forwarding for your virtual machine. In the menu bar above your VM, go to Machine>Settings>Network>Advanced>Port Forwarding and add the following rule: Host port: 8443, Guest port: 443 Leave protocol as TCP, leave host IP and guest IP blank. Name doesn’t matter. Save the changes.

Now update your configuration. Run cd ~/src/reddit/r2/ && nano development.updateand change the file so it looks as follows:

# after editing this file, run “make ini” to
# generate a new development.ini
# global debug flag — displays pylons stacktrace rather than 500 page on error
# when true
# WARNING: a pylons stacktrace allows remote code execution.
# Make sure this is false
# if your server is publicly accessible.
debug = false
disable_ads = true
disable_captcha = true
disable_ratelimit = true
disable_require_admin_otp = true
domain =
oauth_domain =
https_endpoint =
disable_wiki = false
uncompressedJS = true
min_membership_create_community = 0
plugins =
media_provider = filesystem
media_fs_root = /srv/www/media
media_fs_base_url_http = http://%(domain)s/media/
port = 8001

Save using Ctrl-X then y. Then run make ini followed by sudo reddit-restart.

Making Third-Party Apps Work

Some differences in the API between the open source version of Reddit and the current version of Reddit break third-party apps, but can easily be fixed using a reverse-proxy. Users of the app and website connect to the reverse proxy server, which then forwards the request to the actual Reddit instance, making any necessary compatibility adjustments to incoming requests and outgoing responses along the way.

On your host machine, download and install/extract the latest version of OpenResty, which is an nginx-based server with Lua scripting support. Update conf/nginx.conf to read as follows:

worker_processes 1;
events {
worker_connections 1024;
http {
map_hash_bucket_size 512;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;

# remove unsupported OAuth scopes
map $request_uri $new_uri {
/api/v1/authorize.compact?client_id=5JHxEu-4wnFfBA&response_type=code&state=RedditKit&redirect_uri=apollo%3A%2F%2Freddit-oauth&duration=permanent&scope=account%2Ccreddits%2Cedit%2Cflair%2Chistory%2Cidentity%2Clivemanage%2Cmodconfig%2Cmodflair%2Cmodlog%2Cmodothers%2Cmodposts%2Cmodself%2Cmodwiki%2Cmysubreddits%2Cprivatemessages%2Cread%2Creport%2Csave%2Csubmit%2Csubscribe%2Cvote%2Cwikiedit%2Cwikiread%2Cmodcontributors%2Cmodtraffic%2Cmodmail%2Cstructuredstyles /api/v1/authorize.compact?client_id=5JHxEu-4wnFfBA&response_type=code&state=RedditKit&redirect_uri=apollo%3A%2F%2Freddit-oauth&duration=permanent&scope=account%2Ccreddits%2Cedit%2Cflair%2Chistory%2Cidentity%2Cmodconfig%2Cmodflair%2Cmodlog%2Cmodothers%2Cmodposts%2Cmodself%2Cmodwiki%2Cmysubreddits%2Cprivatemessages%2Cread%2Creport%2Csave%2Csubmit%2Csubscribe%2Cvote%2Cwikiedit%2Cwikiread%2Cmodcontributors%2Cmodtraffic;

Leave a Reply

Your email address will not be published. Required fields are marked *

GIPHY App Key not set. Please check settings

Surprising Outcome: Rare Tennis Matchup between Novak Djokovic and Taro Daniel at BNP Paribas Open 2018.

Discussion avec Ivan de Lastours de la BPI : Comment la France investit-elle dans les cryptomonnaies ? 🤔