2018-07-28 17:33:41 +02:00
|
|
|
This assumes that you have Docker (version 17.05 or greater)
|
|
|
|
and Docker Compose (version 1.6.0 or greater) already installed.
|
2016-03-19 21:37:04 +01:00
|
|
|
|
2018-07-12 05:30:13 +02:00
|
|
|
### Prepare things
|
2016-03-19 21:37:04 +01:00
|
|
|
|
2019-10-25 18:48:22 +02:00
|
|
|
1. Download the `szurubooru` source:
|
2016-03-19 21:37:04 +01:00
|
|
|
|
2016-04-01 18:45:25 +02:00
|
|
|
```console
|
2018-07-12 05:30:13 +02:00
|
|
|
user@host:~$ git clone https://github.com/rr-/szurubooru.git szuru
|
|
|
|
user@host:~$ cd szuru
|
2018-07-06 01:25:08 +02:00
|
|
|
```
|
2018-07-12 05:30:13 +02:00
|
|
|
2. Configure the application:
|
2018-07-06 01:25:08 +02:00
|
|
|
|
|
|
|
```console
|
2018-08-04 13:19:02 +02:00
|
|
|
user@host:szuru$ cp server/config.yaml.dist server/config.yaml
|
2019-04-05 16:28:18 +02:00
|
|
|
user@host:szuru$ edit server/config.yaml
|
2016-04-01 18:45:25 +02:00
|
|
|
```
|
2016-03-19 21:37:04 +01:00
|
|
|
|
2016-04-21 10:25:46 +02:00
|
|
|
Pay extra attention to these fields:
|
|
|
|
|
2018-07-12 05:30:13 +02:00
|
|
|
- secret
|
2016-04-21 10:25:46 +02:00
|
|
|
- the `smtp` section.
|
2016-03-19 21:37:04 +01:00
|
|
|
|
2018-07-12 05:30:13 +02:00
|
|
|
You can omit lines when you want to use the defaults of that field.
|
2016-03-19 21:37:04 +01:00
|
|
|
|
2018-07-12 05:30:13 +02:00
|
|
|
3. Configure Docker Compose:
|
2016-04-02 14:13:26 +02:00
|
|
|
|
|
|
|
```console
|
2019-08-06 01:15:37 +02:00
|
|
|
user@host:szuru$ cp doc/example.env .env
|
2018-09-24 01:35:42 +02:00
|
|
|
user@host:szuru$ edit .env
|
2016-04-02 14:13:26 +02:00
|
|
|
```
|
|
|
|
|
2018-09-24 01:35:42 +02:00
|
|
|
Change the values of the variables in `.env` as needed.
|
2019-08-06 01:15:37 +02:00
|
|
|
Read the comments to guide you. Note that `.env` should be in the root
|
|
|
|
directory of this repository.
|
2017-01-21 00:08:29 +01:00
|
|
|
|
2018-07-12 05:30:13 +02:00
|
|
|
### Running the Application
|
2016-03-19 21:37:04 +01:00
|
|
|
|
2020-03-08 04:17:51 +01:00
|
|
|
Download containers:
|
|
|
|
```console
|
|
|
|
user@host:szuru$ docker-compose pull
|
|
|
|
```
|
|
|
|
|
|
|
|
For first run, it is recommended to start the database separately:
|
|
|
|
```console
|
|
|
|
user@host:szuru$ docker-compose up -d sql
|
|
|
|
```
|
|
|
|
|
|
|
|
To start all containers:
|
|
|
|
```console
|
|
|
|
user@host:szuru$ docker-compose up -d
|
|
|
|
```
|
|
|
|
|
|
|
|
To view/monitor the application logs:
|
|
|
|
```console
|
|
|
|
user@host:szuru$ docker-compose logs -f
|
|
|
|
# (CTRL+C to exit)
|
|
|
|
```
|
|
|
|
|
|
|
|
To stop all containers:
|
|
|
|
```console
|
|
|
|
user@host:szuru$ docker-compose down
|
|
|
|
```
|
2018-07-25 01:53:29 +02:00
|
|
|
|
|
|
|
### Additional Features
|
|
|
|
|
2019-08-16 03:53:57 +02:00
|
|
|
1. **CLI-level administrative tools**
|
|
|
|
|
|
|
|
You can use the included `szuru-admin` script to perform various
|
|
|
|
administrative tasks such as changing or resetting a user password. To
|
|
|
|
run from docker:
|
|
|
|
|
|
|
|
```console
|
2020-09-01 17:06:59 +02:00
|
|
|
user@host:szuru$ docker-compose run server ./szuru-admin --help
|
2019-08-16 03:53:57 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
will give you a breakdown on all available commands.
|
|
|
|
|
|
|
|
2. **Using a seperate domain to host static files (image content)**
|
2018-07-25 01:53:29 +02:00
|
|
|
|
|
|
|
If you want to host your website on, (`http://example.com/`) but want
|
|
|
|
to serve the images on a different domain, (`http://static.example.com/`)
|
|
|
|
then you can run the backend container with an additional environment
|
|
|
|
variable `DATA_URL=http://static.example.com/`. Make sure that this
|
|
|
|
additional host has access contents to the `/data` volume mounted in the
|
|
|
|
backend.
|
|
|
|
|
2019-08-16 03:53:57 +02:00
|
|
|
3. **Setting a specific base URI for proxying**
|
2018-07-25 01:53:29 +02:00
|
|
|
|
|
|
|
Some users may wish to access the service at a different base URI, such
|
|
|
|
as `http://example.com/szuru/`, commonly when sharing multiple HTTP
|
|
|
|
services on one domain using a reverse proxy. In this case, simply set
|
2019-08-14 13:57:56 +02:00
|
|
|
`BASE_URL="/szuru/"` in your `.env` file.
|
2018-07-25 01:53:29 +02:00
|
|
|
|
2019-08-14 13:57:56 +02:00
|
|
|
Note that this will require a reverse proxy to function. You should set
|
|
|
|
your reverse proxy to proxy `http(s)://example.com/szuru` to
|
2018-07-25 01:53:29 +02:00
|
|
|
`http://<internal IP or hostname of frontend container>/`. For an NGINX
|
|
|
|
reverse proxy, that will appear as:
|
|
|
|
|
|
|
|
```nginx
|
|
|
|
location /szuru {
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_pass http://<internal IP or hostname of frontend container>/;
|
|
|
|
|
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header X-Scheme $scheme;
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
proxy_set_header X-Script-Name /szuru;
|
|
|
|
}
|
|
|
|
```
|
2019-03-08 01:13:04 +01:00
|
|
|
|
2019-08-16 03:53:57 +02:00
|
|
|
4. **Preparing for production**
|
2019-03-08 01:13:04 +01:00
|
|
|
|
|
|
|
If you plan on using szurubooru in a production setting, you may opt to
|
|
|
|
use a reverse proxy for added security and caching capabilities. Start
|
|
|
|
by having the client docker listen only on localhost by changing `PORT`
|
|
|
|
in your `.env` file to `127.0.0.1:8080` instead of simply `:8080`. Then
|
|
|
|
configure NGINX (or your caching/reverse proxy server of your choice)
|
2020-06-05 16:29:52 +02:00
|
|
|
to proxy_pass `http://127.0.0.1:8080`. An example config is shown below:
|
|
|
|
|
|
|
|
```nginx
|
|
|
|
# ideally, use ssl termination + cdn with a provider such as cloudflare.
|
|
|
|
# modify as needed!
|
|
|
|
|
|
|
|
# rate limiting zone
|
|
|
|
# poor man's ddos protection, essentially
|
|
|
|
limit_req_zone $binary_remote_addr zone=throttle:10m rate=25r/s;
|
|
|
|
|
|
|
|
# www -> non-www
|
|
|
|
server {
|
|
|
|
listen 80;
|
|
|
|
listen [::]:80;
|
|
|
|
server_tokens off;
|
|
|
|
server_name www.example.com
|
|
|
|
return 301 http://example.com$request_uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
server {
|
|
|
|
server_name example.com;
|
|
|
|
client_max_body_size 100M;
|
|
|
|
client_body_timeout 30s;
|
|
|
|
server_tokens off;
|
|
|
|
location / {
|
|
|
|
limit_req zone=throttle burst=5 delay=3;
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header X-Scheme $scheme;
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
proxy_set_header X-Script-Name /szuru;
|
|
|
|
error_page 500 501 502 504 505 506 507 508 509 510 511 @err;
|
|
|
|
error_page 503 @throttle;
|
|
|
|
}
|
|
|
|
|
|
|
|
location @err {
|
|
|
|
return 500 "server error. please try again later.";
|
|
|
|
default_type text/plain;
|
|
|
|
}
|
|
|
|
location @throttle {
|
|
|
|
return 503 "we've detected abuse on your ip. please wait and try again later.";
|
|
|
|
default_type text/plain;
|
|
|
|
}
|
|
|
|
listen 80;
|
|
|
|
listen [::]:80;
|
|
|
|
}
|
|
|
|
```
|