From 968793d36e1174e752ce7e047b32b374085e54fa Mon Sep 17 00:00:00 2001 From: Kuchenmampfer <79256346+Kuchenmampfer@users.noreply.github.com> Date: Mon, 7 Nov 2022 17:53:38 +0000 Subject: [PATCH] Added reverse proxy example for Caddy --- README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d504326..543ed7e 100644 --- a/README.md +++ b/README.md @@ -341,9 +341,9 @@ Help us by opening a pull request! In short, no. [You need to buy an API key](https://buy.stripe.com/3cs4j3a4u4c8d3i289). You can always run LibreTranslate for free on your own server of course. -### Can I use LibreTranslate behind a reverse proxy, like Apache2? +### Can I use LibreTranslate behind a reverse proxy, like Apache2 or Caddy? -Yes, here is an example Apache2 config that redirects a subdomain (with HTTPS certificate) to LibreTranslate running on a docker at localhost. +Yes, here are config examples for Apache2 and Caddy that redirect a subdomain (with HTTPS certificate) to LibreTranslate running on a docker at localhost. ``` sudo docker run -ti --rm -p 127.0.0.1:5000:5000 libretranslate/libretranslate ``` @@ -393,6 +393,23 @@ Add this to an existing site config, or a new file in `/etc/apache2/sites-availa To get a HTTPS subdomain certificate, install `certbot` (snap), run `sudo certbot certonly --manual --preferred-challenges dns` and enter your information (with `subdomain.domain.tld` as the domain). Add a DNS TXT record with your domain registrar when asked. This will save your certificate and key to `/etc/letsencrypt/live/{subdomain.domain.tld}/`. Alternatively, comment the SSL lines out if you don't want to use HTTPS. +
+Caddy config +
+ +Replace [YOUR_DOMAIN] with your full domain; for example, `translate.domain.tld` or `libretranslate.domain.tld`. + +```Caddyfile +#Libretranslate +[YOUR_DOMAIN] { + reverse_proxy localhost:5000 +} +``` + +Add this to an existing Caddyfile or save it as `Caddyfile` in any directory and run `sudo caddy reload` in that same directory. + +
+ ## Credits This work is largely possible thanks to [Argos Translate](https://github.com/argosopentech/argos-translate), which powers the translation engine.