From f055f1d0aa5f595cf44822a0653c470913dcc97a Mon Sep 17 00:00:00 2001 From: birjolaxew Date: Fri, 30 Oct 2020 05:43:45 +0100 Subject: [PATCH] Add reverse-proxy configuration for existing NGINX installation --- reverse-proxy/README.md | 16 ++++++++++++++++ reverse-proxy/nginx/plausible | 9 +++++++++ 2 files changed, 25 insertions(+) create mode 100644 reverse-proxy/nginx/plausible diff --git a/reverse-proxy/README.md b/reverse-proxy/README.md index b37ae18..868b2fe 100644 --- a/reverse-proxy/README.md +++ b/reverse-proxy/README.md @@ -7,3 +7,19 @@ If you aren't running an existing reverse proxy, then you can use the [`caddy-ge ```shell $ docker-compose -f docker-compose.yml -f reverse-proxy/docker-compose.caddy-gen.yml up ``` + +## Existing reverse proxy + +If you are already running a reverse proxy, then the above will not work as it will clash with the existing port bindings. You should instead use one of the available configuration files: + +### NGINX + +If you already have NGINX running as a system service, use the configuration file in the `nginx` directory. + +Edit the file `reverse-proxy/nginx/plausible` to contain the domain name you use for your server, then copy it into NGINX's configuration folder. Enable it by creating a symlink in NGINX's enabled sites folder. Finally use Certbot to create a TLS certificate for your site. + +```shell +$ sudo cp reverse-proxy/nginx/plausible /etc/nginx/sites-available +$ sudo ln -s /etc/nginx/sites-available/plausible /etc/nginx/sites-enabled/plausible +$ sudo certbot --nginx +``` diff --git a/reverse-proxy/nginx/plausible b/reverse-proxy/nginx/plausible new file mode 100644 index 0000000..ba83b27 --- /dev/null +++ b/reverse-proxy/nginx/plausible @@ -0,0 +1,9 @@ +server { + # replace example.com with your domain name + server_name example.com; + + location / { + proxy_pass http://127.0.0.1:8000; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +}