@@ -122,13 +122,6 @@ The gateway can be stopped anytime with the following command:
122
122
123
123
$ brig gateway stop
124
124
125
- .. note ::
126
-
127
- If you want to forward the gateway to the outside, but do not own
128
- a dedicated server, you can forward port 6001 to your computer. With this
129
- setup you should also get a certficate which in turn requires a DNS name.
130
- An easy way to get one is to use dynamic DNS.
131
-
132
125
There is also a small helper that will print you a nice hyperlink to a certain
133
126
file called ``brig gateway url ``:
134
127
@@ -181,100 +174,31 @@ For your convenience there are a bunch of presets which will do the work for you
181
174
Running the gateway with HTTPS
182
175
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
183
176
184
- The gateway has built-in support for `LetsEncrypt <https://letsencrypt.org/ >`_.
185
- If the gateway is reachable under a DNS name, it is straightforward to get
186
- a TLS certificate for it. In total there are three methods:
187
-
188
- **Method one: Automatic: ** This works by telling the gateway the domain name.
189
- Since the retrieval process for getting a certificate involves binding on port 80,
190
- you need to prepare the brig binary to allow that without running as root:
191
-
192
- .. code-block :: bash
193
-
194
- # You need to restart the brig daemon for that.
195
- # Every next brig command will restart it.
196
- $ brig daemon quit
197
- $ sudo setcap CAP_NET_BIND_SERVICE=+ep $( which brig)
198
-
199
- Afterwards you can set the domain in the config. If the gateway is already running,
200
- it will restart immediately.
201
-
202
- .. code-block :: bash
203
-
204
- $ brig cfg set gateway.cert.domain your.domain.org
205
-
206
- You can check after a few seconds if it worked by checking if the ``certfile `` and ``keyfile ``
207
- was set:
208
-
209
- .. code-block :: bash
210
-
211
- $ brig cfg get gateway.cert.certfile
212
- /home/user/.cache/brig/your.domain.org_cert.pem
213
- $ brig cfg get gateway.cert.keyfile
214
- /home/user/.cache/brig/your.domain.org_key.pem
215
- $ curl -i https://your.domain.org:6001
216
- HTTP/2 200
217
- vary: Accept-Encoding
218
- content-type: text/plain; charset=utf-8
219
- content-length: 38
220
- date: Wed, 05 Dec 2018 11:53:57 GMT
221
-
222
- < html>
223
- ...
224
- < /html>
225
-
226
-
227
- This method has the advantage that the certificate can be updated automatically
228
- before it expires.
229
-
230
- **Method two: Half-Automated: **
231
-
232
- If the above did not work for whatever reasons, you can try to get a certificate manually.
233
- There is a built-in helper called ``brig gateway cert `` that can help you doing that:
234
-
235
- .. code-block :: bash
236
-
237
- $ brig gateway cert your.domain.org
238
- You are not root. We need root rights to bind to port 80.
239
- I will re-execute this command for you as:
240
- $ sudo brig gateway cert nwzmlh4iouqikobq.myfritz.net --cache-dir /home/sahib/.cache/brig
241
-
242
- A certificate was downloaded successfully.
243
- Successfully set the gateway config to use the certificate.
244
- Note that you have to re-run this command every 90 days currently.
245
-
246
- If successful, this command will set the ``certfile `` and ``keyfile `` config
247
- values for you. You can test if the change worked by doing the same procedure
248
- as in *method one *. Sadly, you have to re-execute once the certificate expires.
249
-
250
- **Method three: Manual: **
251
-
252
- If you already own a certificate you can make the gateway use it by setting the path
253
- to the public certificate and the private key file:
254
-
255
- .. code-block :: bash
256
-
257
- $ brig cfg set gateway.cert.certfile /path/to/cert.pem
258
- $ brig cfg set gateway.cert.keyfile /path/to/key.pem
259
-
260
- If you do not own a certificate yet, but want to setup an automated way to
261
- download one for usages outside of brig, you should look into
262
- `certbot <https://certbot.eff.org/docs/ >`_.
263
-
264
- Redirecting HTTP traffic
265
- ~~~~~~~~~~~~~~~~~~~~~~~~
266
-
267
- This section only applies to you if you choose **method one ** from above and
268
- want to run the gateway on port 80 (http) and port 443 (https). This has the
269
- advantage that a user does not need to specify the port in a gateway URL have
270
- which looks a little bit less *»scary« *. With this setup all traffic on port 80
271
- will be redirected directly to port 443.
272
-
273
- .. code-block :: bash
274
-
275
- $ brig cfg set gateway.port 443
276
- $ brig cfg set gateway.cert.redirect.enabled true
277
- $ brig cfg set gateway.cert.redirect.http_port 80
177
+ By default, we run with ``http `` only. If you want to expose the gateway under
178
+ a domain to the internet you should secure it with ``https ``. Since brig's
179
+ gateway might is likely not the only service you want to expose we recommend a
180
+ webserver like `Caddy `_ (which is great software in general!) that
181
+ automatically fetches certificates and reverse-proxies traffic to the gateway.
182
+ A minimal ``Caddyfile `` can look like this:
183
+
184
+ .. code-block ::
185
+
186
+ # Assumption:
187
+ # brig gateway runs on the same server as Caddy
188
+ # and is reachable under localhost:6001.
189
+ your.domain.org {
190
+ route /gateway/* {
191
+ uri strip_prefix /gateway
192
+ reverse_proxy http://localhost:6001
193
+ }
194
+ }
195
+
196
+ With this setup, your gateway would be reachable under
197
+ ``https://your.domain.org/gateway ``. You can of course choose a different
198
+ route or even a sub-domain. Maybe you also want to setup compression or require
199
+ a client certificate. Refer to the Caddy documentation for more information.
200
+
201
+ .. _Caddy : https://caddyserver.com/docs/getting-started
278
202
279
203
Allowing anonymous access
280
204
~~~~~~~~~~~~~~~~~~~~~~~~~
0 commit comments