Skip to content

Nginx reverse-proxy with caching and webhook triggered cache-invalidation

Notifications You must be signed in to change notification settings

TJBANEY/reverse-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Reverse Proxy with Cache Invalidation

Nginx reverse-proxy with SSL termination, and a simple cache-invalidation system designed to automate cache invalidation by handling Webflow webhook requests triggered site_publish events

1. Nginx Installation

Install Nginx on your server. Nginx was the chosen reverse-proxy solution

sudo yum install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx

2. Python and FastAPI Setup

Install Python 3.11

sudo yum update -y

sudo yum install -y gcc openssl-devel bzip2-devel libffi-devel zlib-devel bzip2 readline-devel sqlite sqlite-devel tk-devel xz-devel

curl https://pyenv.run | bash

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"

source ~/.bashrc

pyenv install 3.11.0
pyenv global 3.11.0

Set Up FastAPI

# Install Python dependencies
pip install fastapi uvicorn

# Run FastAPI in the background by running the following command from directory where main.py is located
nohup uvicorn main:app --host 0.0.0.0 --port 8000 &

3. Webflow Webhook Setup and Configuration

Set up a Webflow webhook for "site_publish" events. The webhook needs to point to the reverse-proxy server at path, /invalidate-cache. The webhook request will be directed to the FastAPI web-server running on the same machine. This web-server will handle that request by invalidating the site's cache by removing cached files from disk.


4. Nginx SSL Termination

For HTTPS

sudo yum install certbot python3-certbot-nginx

sudo certbot --nginx -d reverse-proxy.domain.com -d www.reverse-proxy.domain.com

About

Nginx reverse-proxy with caching and webhook triggered cache-invalidation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages