Skip to content

Commit e77d828

Browse files
authored
Fix symfony generating http URLs with anubis (#1709)
1 parent 4e8eb46 commit e77d828

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/02-admin/03-optional-features/07-anubis.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,19 @@ server {
180180
location / {
181181
# try to serve file directly, fallback to index.php
182182
try_files $uri /index.php$is_args$args;
183+
184+
# lie to Symfony that the request is an HTTPS one, so it generates HTTPS URLs
185+
fastcgi_param SERVER_PORT "443";
186+
fastcgi_param HTTPS "on";
183187
}
184188
}
185189
```
186190

187191
As you can see instead of serving Mbin directly we proxy it through the Anubis service. Anubis is then going to decide whether to call the UNIX socket that the actual Mbin site is served over or if it presents a challenge to the client (or straight up denying it).
188192

193+
In the actual Mbin call we lie to Symfony that the request is coming from port 443 (`fastcgi_param SERVER_PORT`) and the https scheme (`fastcgi_param HTTPS`).
194+
The reason is that it will otherwise generate HTTP URLs which are incompatible with some other fediverse software, like Lemmy.
195+
189196
### The long one
190197

191198
```nginx
@@ -339,6 +346,10 @@ server {
339346
include fastcgi_params;
340347
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
341348
fastcgi_param DOCUMENT_ROOT $realpath_root;
349+
350+
# lie to Symfony that the request is an HTTPS one, so it generates HTTPS URLs
351+
fastcgi_param SERVER_PORT "443";
352+
fastcgi_param HTTPS "on";
342353
343354
# Prevents URIs that include the front controller. This will 404:
344355
# http://domain.tld/index.php/some-path
@@ -375,6 +386,14 @@ server {
375386
}
376387
```
377388

389+
To test whether Mbin correctly uses the HTTPS scheme, you can run this command (replaced with you URL and username):
390+
391+
```bash
392+
curl --header "Accept: application/activity+json" https://example.mbin/u/admin | jq
393+
```
394+
395+
The `| jq` part outputs formatted json which should make this easier to see. There should not be any `http://` URLs in this output.
396+
378397
### Take it live
379398

380399
To start routing the traffic through Anubis nginx has to be restarted (not just reloaded), because of the new socket that needs to be created. But before we do that we should check the config for validity:

0 commit comments

Comments
 (0)