2019-07-12 16:07:24 +02:00
## Requirements
2021-05-19 11:17:13 +02:00
2020-10-15 18:52:41 +02:00
This document describes how to do a full deployment of Send on your own Linux server. You will need:
2019-07-12 16:07:24 +02:00
2021-05-19 11:17:13 +02:00
* A working (and ideally somewhat recent) installation of NodeJS and npm
* Git
* Apache webserver
2019-07-12 16:07:24 +02:00
* Optionally telnet, to be able to quickly check your installation
2021-05-19 11:17:13 +02:00
For example in Debian/Ubuntu systems:
2019-07-12 16:07:24 +02:00
2021-05-19 11:17:13 +02:00
```bash
sudo apt install git apache2 nodejs npm telnet
```
2019-07-12 16:07:24 +02:00
## Building
2021-05-19 11:17:13 +02:00
2019-07-12 16:07:24 +02:00
* We assume an already configured virtual-host on your webserver with an existing empty htdocs folder
2020-10-15 18:52:41 +02:00
* First, remove that htdocs folder - we will replace it with Send's version now
2021-05-06 08:51:55 +02:00
* git clone https://github.com/timvisee/send.git htdocs
2019-07-12 16:07:24 +02:00
* Make now sure you are NOT root but rather the user your webserver is serving files under (e.g. "su www-data" or whoever the owner of your htdocs folder is)
* npm install
* npm run build
## Running
2021-05-19 11:17:13 +02:00
2020-10-15 18:52:41 +02:00
To have a permanently running version of Send as a background process:
2019-07-12 16:07:24 +02:00
2021-05-19 11:17:13 +02:00
* Create a file `run.sh` with:
```bash
2019-07-12 16:07:24 +02:00
#!/bin/bash
nohup su www-data -c "npm run prod" 2>/dev/null &
```
2021-05-19 11:17:13 +02:00
* Execute the script:
```bash
chmod +x run.sh
./run.sh
```
2019-07-12 16:07:24 +02:00
2020-10-15 18:52:41 +02:00
Now the Send backend should be running on port 1443. You can check with:
2021-05-19 11:17:13 +02:00
```bash
telnet localhost 1443
```
2019-07-12 16:07:24 +02:00
## Reverse Proxy
2021-05-19 11:17:13 +02:00
2020-10-15 18:52:41 +02:00
Of course, we don't want to expose the service on port 1443. Instead we want our normal webserver to forward all requests to Send ("Reverse proxy").
2019-07-12 16:07:24 +02:00
# Apache webserver
2021-05-19 11:17:13 +02:00
* Enable Apache required modules:
```bash
sudo a2enmod headers
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_wstunnel
sudo a2enmod rewrite
```
2019-07-12 16:07:24 +02:00
2021-05-19 11:17:13 +02:00
* Edit your Apache virtual host configuration file, insert this:
2019-07-12 16:07:24 +02:00
```
2021-05-19 11:17:13 +02:00
# Enable rewrite engine
RewriteEngine on
# Make sure the original domain name is forwarded to Send
# Otherwise the generated URLs will be wrong
ProxyPreserveHost on
2019-07-12 16:07:24 +02:00
2021-05-19 11:17:13 +02:00
# Make sure the generated URL is https://
RequestHeader set X-Forwarded-Proto https
2019-07-12 16:07:24 +02:00
2021-05-19 11:17:13 +02:00
# If it's a normal file (e.g. PNG, CSS) just return it
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .* - [L]
2019-07-12 16:07:24 +02:00
2021-05-19 11:17:13 +02:00
# If it's a websocket connection, redirect it to a Send WS connection
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://127.0.0.1:1443/$1 [P,L]
# Otherwise redirect it to a normal HTTP connection
RewriteRule ^/(.*)$ http://127.0.0.1:1443/$1 [P,QSA]
ProxyPassReverse "/" "http://127.0.0.1:1443"
```
2019-07-12 16:07:24 +02:00
2021-05-19 11:17:13 +02:00
* Test configuration and restart Apache:
2019-07-12 16:07:24 +02:00
2021-05-19 11:17:13 +02:00
```bash
sudo apache2ctl configtest
sudo systemctl restart apache2
2019-07-12 16:07:24 +02:00
```