Merge pull request #337 from Kuchenmampfer/main

Added reverse proxy example for Caddy
This commit is contained in:
Piero Toffanin 2022-11-07 13:26:04 -05:00 committed by GitHub
commit 65e6a7f262
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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.
</details>
<details>
<summary>Caddy config</summary>
<br>
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.
</details>
## Credits
This work is largely possible thanks to [Argos Translate](https://github.com/argosopentech/argos-translate), which powers the translation engine.