Skip to content

Commit 0147716

Browse files
authored
Merge pull request #278 from sunstep/master
Add compression support to each configuration and some adjustments to the documentation
2 parents 0727bed + 5850f2f commit 0147716

File tree

1 file changed

+83
-96
lines changed

1 file changed

+83
-96
lines changed

docs/how_to_setup_reverse_proxy.md

Lines changed: 83 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,26 @@ Make sure to exclude "http://" or "https://" from the environment variable. ⚠
88
At the time of writing this, the way to set the environment variable is to edit the docker-compose.yml file. Find all APPLICATION_HOSTS entries in the docker-compose.yml file and make sure to include your domain name. Example:
99

1010
```yaml
11-
dawarich_app:
11+
dawarich_app:
1212
image: freikin/dawarich:latest
1313
container_name: dawarich_app
14+
...
1415
environment:
15-
APPLICATION_HOSTS: "yourhost.com,www.yourhost.com,127.0.0.1"
16+
...
17+
APPLICATION_HOST: "yourhost.com" <------------------------------ Edit this
18+
APPLICATION_HOSTS: "yourhost.com,www.yourhost.com,127.0.0.1" <-- Edit this
19+
```
20+
21+
```yaml
22+
dawarich_sidekiq:
23+
image: freikin/dawarich:latest
24+
container_name: dawarich_sidekiq
25+
...
26+
environment:
27+
...
28+
APPLICATION_HOST: "yourhost.com" <------------------------------ Edit this
29+
APPLICATION_HOSTS: "yourhost.com,www.yourhost.com,127.0.0.1" <-- Edit this
30+
...
1631
```
1732

1833
For a Synology install, refer to **[Synology Install Tutorial](How_to_install_Dawarich_on_Synology.md)**. In this page, it is explained how to set the APPLICATION_HOSTS environment variable.
@@ -24,13 +39,42 @@ Now that the app works with a domain name, the server needs to be set up to use
2439
Below are examples of reverse proxy configurations.
2540

2641
### Nginx
27-
```
42+
```nginx
2843
server {
2944
3045
listen 80;
3146
listen [::]:80;
3247
server_name example.com;
3348
49+
brotli on;
50+
brotli_comp_level 6;
51+
brotli_types
52+
text/css
53+
text/plain
54+
text/xml
55+
text/x-component
56+
text/javascript
57+
application/x-javascript
58+
application/javascript
59+
application/json
60+
application/manifest+json
61+
application/vnd.api+json
62+
application/xml
63+
application/xhtml+xml
64+
application/rss+xml
65+
application/atom+xml
66+
application/vnd.ms-fontobject
67+
application/x-font-ttf
68+
application/x-font-opentype
69+
application/x-font-truetype
70+
image/svg+xml
71+
image/x-icon
72+
image/vnd.microsoft.icon
73+
font/ttf
74+
font/eot
75+
font/otf
76+
font/opentype;
77+
3478
location / {
3579
proxy_set_header X-Real-IP $remote_addr;
3680
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -54,29 +98,34 @@ For Apache2, you might need to enable some modules. Start by entering the follow
5498
sudo a2enmod proxy
5599
sudo a2enmod proxy_http
56100
sudo a2enmod headers
101+
sudo a2enmod brotli
57102
```
58103

59104
With the above commands entered, the configuration below should work properly.
60105

61-
```
106+
```apache
62107
<VirtualHost *:80>
63-
ServerName example.com
64-
65-
ProxyRequests Off
66-
ProxyPreserveHost On
67-
68-
<Proxy *>
69-
Require all granted
70-
</Proxy>
71-
72-
Header always set X-Real-IP %{REMOTE_ADDR}s
73-
Header always set X-Forwarded-For %{REMOTE_ADDR}s
74-
Header always set X-Forwarded-Proto https
75-
Header always set X-Forwarded-Server %{SERVER_NAME}s
76-
Header always set Host %{HTTP_HOST}s
77-
78-
ProxyPass / http://127.0.0.1:3000/
79-
ProxyPassReverse / http://127.0.0.1:3000/
108+
ServerName example.com
109+
110+
ProxyRequests Off
111+
ProxyPreserveHost On
112+
113+
<Proxy *>
114+
Require all granted
115+
</Proxy>
116+
117+
Header always set X-Real-IP %{REMOTE_ADDR}s
118+
Header always set X-Forwarded-For %{REMOTE_ADDR}s
119+
Header always set X-Forwarded-Proto https
120+
Header always set X-Forwarded-Server %{SERVER_NAME}s
121+
Header always set Host %{HTTP_HOST}s
122+
123+
SetOutputFilter BROTLI
124+
AddOutputFilterByType BROTLI_COMPRESS text/css text/plain text/xml text/javascript application/javascript application/json application/manifest+json application/vnd.api+json application/xml application/xhtml+xml application/rss+xml application/atom+xml application/vnd.ms-fontobject application/x-font-ttf application/x-font-opentype application/x-font-truetype image/svg+xml image/x-icon image/vnd.microsoft.icon font/ttf font/eot font/otf font/opentype
125+
BrotliCompressionQuality 6
126+
127+
ProxyPass / http://127.0.0.1:3000/
128+
ProxyPassReverse / http://127.0.0.1:3000/
80129
81130
</VirtualHost>
82131
```
@@ -94,97 +143,35 @@ Second, create a Docker network for Dawarich to use as the backend network:
94143
docker network create dawarich
95144
```
96145

97-
Adjust your Dawarich docker-compose.yaml so that the web app is exposed to your new network and the backend Dawarich network:
98-
```
99-
version: '3'
146+
Adjust the following part of your Dawarich docker-compose.yaml, so that the web app is exposed to your new network and the backend Dawarich network:
147+
```yaml
100148
networks:
101149
dawarich:
102150
frontend:
103151
external: true
104152
services:
105-
dawarich_redis:
106-
image: redis:7.0-alpine
107-
command: redis-server
108-
networks:
109-
- dawarich
110-
volumes:
111-
- ./dawarich/redis:/var/shared/redis
112-
dawarich_db:
113-
image: postgres:14.2-alpine
114-
container_name: dawarich_db
115-
volumes:
116-
- ./dawarich/db:/var/lib/postgresql/data
117-
- ./dawarich/shared:/var/shared
118-
networks:
119-
- dawarich
120-
environment:
121-
POSTGRES_USER: postgres
122-
POSTGRES_PASSWORD: password
123-
dawarich_app:
124-
image: freikin/dawarich:latest
125-
container_name: dawarich_app
126-
volumes:
127-
- ./dawarich/gems:/usr/local/bundle/gems
128-
- ./dawarich/public:/var/app/public
129-
networks:
130-
- dawarich
131-
- frontend
132-
stdin_open: true
133-
tty: true
134-
entrypoint: dev-entrypoint.sh
135-
command: ['bin/dev']
136-
restart: on-failure
137-
environment:
138-
RAILS_ENV: development
139-
REDIS_URL: redis://dawarich_redis:6379/0
140-
DATABASE_HOST: dawarich_db
141-
DATABASE_USERNAME: postgres
142-
DATABASE_PASSWORD: password
143-
DATABASE_NAME: dawarich_development
144-
MIN_MINUTES_SPENT_IN_CITY: 60
145-
APPLICATION_HOSTS: <YOUR FQDN HERE (ex. dawarich.example.com)>
146-
TIME_ZONE: America/New_York
147-
depends_on:
148-
- dawarich_db
149-
- dawarich_redis
150-
dawarich_sidekiq:
151-
image: freikin/dawarich:latest
152-
container_name: dawarich_sidekiq
153-
volumes:
154-
- ./dawarich/gems:/usr/local/bundle/gems
155-
- ./dawarich/public:/var/app/public
156-
networks:
157-
- dawarich
158-
stdin_open: true
159-
tty: true
160-
entrypoint: dev-entrypoint.sh
161-
command: ['sidekiq']
162-
restart: on-failure
163-
environment:
164-
RAILS_ENV: development
165-
REDIS_URL: redis://dawarich_redis:6379/0
166-
DATABASE_HOST: dawarich_db
167-
DATABASE_USERNAME: postgres
168-
DATABASE_PASSWORD: password
169-
DATABASE_NAME: dawarich_development
170-
APPLICATION_HOSTS: <YOUR FQDN HERE (ex. dawarich.example.com)>
171-
depends_on:
172-
- dawarich_db
173-
- dawarich_redis
174-
- dawarich_app
153+
...
175154
```
176155
177156
Lastly, edit your Caddy config as needed:
178-
```
157+
```caddy
179158
{
180159
http_port 80
181160
https_port 443
182161
}
183162

184-
<YOUR FQDN HERE (ex. dawarich.example.com)> {
163+
timeline.example.com {
185164
reverse_proxy dawarich_app:3000
165+
166+
encode brotli {
167+
match {
168+
content_type text/css text/plain text/xml text/x-component text/javascript application/x-javascript application/javascript application/json application/manifest+json application/vnd.api+json application/xml application/xhtml+xml application/rss+xml application/atom+xml application/vnd.ms-fontobject application/x-font-ttf application/x-font-opentype application/x-font-truetype image/svg+xml image/x-icon image/vnd.microsoft.icon font/ttf font/eot font/otf font/opentype
169+
}
170+
}
186171
}
172+
187173
```
174+
timeline.example.com is an example, use your own (sub) domain.
188175

189176
---
190177

0 commit comments

Comments
 (0)