nextcloud / social

🎉 Social can be used for work, or to connect to the fediverse!
https://apps.nextcloud.com/apps/social
GNU Affero General Public License v3.0
488 stars 59 forks source link

Help with redirects breaking Social app for Nextcloud in subdirectories #1808

Open riparise opened 1 year ago

riparise commented 1 year ago

I cannot follow users or see any post in the social app. I manage to narrow down the issue, but I fail to find a solution. Any help is much appreciated.

My nextcloud was installed via Softaculos in cpanel. I have no root access. The Nextcloud is running in a directory under the root of my website, which is served via Apache.

Here are some parts of the error log generated when I try to follow someone in the Social app:

[social] Info: Error while managing request: {
  "protocols":["https"],
  "used_protocol":"https",
  "port":0,
  "host":"lemmy.ml",
  "url":"/u/SOMELEMMYUSER/inbox",
  ...
  "Signature":"keyId="https://MYDOMAIN.COM/nextcloud/nextcloud/apps/social/@USERNAME#main-key",
  ...
  "id":"https://MYDOMAIN.COM/nextcloud/10c43d04-5927-4ba5-b39c-26e722753670",
  "type":"Follow",
  "actor":"https://MYDOMAIN.COM/nextcloud/nextcloud/apps/social/@USERNAME",
  ...
}

As you can see, sometimes the URL is correctly formed (MYDOMAIN.COM/nextcloud/whatever) and sometimes it is wrong (MYDOMAIN.COM/nextcloud/nextcloud/whatever), which I assume is the cause of the issue.

The .htaccess file inside the root of the website looks like this:

RewriteEngine On
RewriteRule ^$ /nextcloud [L]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteCond %{HTTP_HOST} ^MYDOMAIN\.COM$ [OR]
RewriteCond %{HTTP_HOST} ^www\.MYDOMAIN\.COM$
RewriteRule ^(.*)$ "https\:\/\/MYDOMAIN\.COM\/$1" [R=301,L]
RewriteRule ^\.well-known/carddav /nextcloud/remote.php/dav [R=301,L]
RewriteRule ^\.well-known/caldav /nextcloud/remote.php/dav [R=301,L]
RewriteRule ^/.well-known/webfinger /nextcloud/index.php/.well-known/webfinger [R=301,L]
RewriteRule ^\.well-known/nodeinfo /nextcloud/index.php/.well-known/nodeinfo [R=301,L]

It is weird because all the redirects seem to work fine:

If I go to MYDOMAIN.COM/nextcloud/index.php/.well-known/webfinger I get the following message: {"message":"webfinger not supported"}

If I go to MYDOMAIN.COM/nextcloud/index.php/.well-known/nodeinfo I get the following message: {"links": {"rel":"http:\/\/nodeinfo.diaspora.software\/ns\/schema\/2.0","href":"https:\/\/MYDOMAIN>COM\/nextcloud\/apps\/social\/.well-known\/nodeinfo\/2.0"}]}

In the MYDOMAIN.COM/nextcloud/apps/social/.well-known/nodeinfo/2.0 I can see: {"version":"2.0","software":{"name":"My Nextcloud","version":"0.6.1"},"protocols":["activitypub"],"rootUrl":"https:\/\/MYDOMAIN.COM\/nextcloud\/apps\/social","usage":[],"openRegistrations":false}

I am not sure if this is a general bug on configuration issue on my side. If latter is the case, please feel free to close the issue

Thatoo commented 7 months ago

I managed to be able to be followed. For that, I changed the redirect nginx rule location = /.well-known/webfinger { return 301 /nuage-nextcloud/index.php$uri; } to location = /.well-known/webfinger { return 301 /nuage-nextcloud/index.php$request_uri; }

However, I still can't follow, I face the same issue as here : https://github.com/nextcloud/social/issues/1813