Apache Reverse Proxy Setup and Android App - how to verify?

I have a Nextcloud installation running already. However I wanted to switch to https thus I added a reverse proxy. I created the Apache proxy setup myself and it seems to run when Nextcloud is accessed via web browser. Now I want to attach the Nextcloud app from my Android phone, and that hangs on the https url while it works on the direct http url. Thus I suspect my proxy setup is not complete.

Is there some tutorial how to setup reverse proxies? Or is there some kind of test procedure to check if the Nextcloud setup is correct?

So far no response. It seems noone uses reverse proxies or I am the only one to face a problem with them…

Hi @hiran , i use reverse proxy but not on nextcloud.
maybe adding this to you reverse proxy can help you :

SetEnvIf Host "^(.)$" THE_HOST=$1
RequestHeader setifempty X-Forwarded-Proto https
RequestHeader setifempty X-Forwarded-Host %{THE_HOST}e
ProxyAddHeaders Off
RemoteIPHeader X-Forwarded-For
ProxyPassMatch (.
)(/websocket)$ “ws://127.0.0.1:8082/$1$2”
ProxyPass / http://127.0.0.1:8082/
ProxyPassReverse / http://127.0.0.1:8082/

don’t forget to enable apache module :
sudo a2enmod proxy_http ssl proxy_wstunnel remoteip

maybe you should see this : Reverse proxy — Nextcloud latest Administration Manual latest documentation

Thank you for that response. Our setups look to some degree similar, with exception of the websockets-related line. Maybe that’s what is missing for me.

But exactly that line is creating a headache for me. If copied verbatim, httpd will not startup with an error message

AH00526: Syntax error on line XXX of /usr/local/apache2/conf/httpd.conf:
ProxyPass Unable to parse URL: \xe2\x80\x9cws://nextcloud/$1$2\xe2\x80\x9d

Looking at mod_proxy - Apache HTTP Server Version 2.4, the line you mention should be ok but it is not. Do you really intend to copy only one character via $1? Or should it mean something like

ProxyPassMatch (.*)(/websocket)$ “ws://127.0.0.1:8082/$1$2”

BTW, the fine manual at Reverse proxy — Nextcloud latest Administration Manual latest documentation does not mention the websockets at all.

Update: The bad part was not the regex nor the fomula. While I was looking at the first parameter, it was actually the second. I guess during cut&paster the quotation marks were not the right ones.

So my setup is running again now, but not showing any change for the Android app. That one still hangs after login.

@hiran have you try on other devices ( phones)?
Which type of installation do you use?

I have been running this container for a while now:
https://hub.docker.com/_/nextcloud
Which means I started off with Nextcloud 17 (I think) and upgraded since then. Meanwhile I am running nextcloud:20.

I do not have another phone to test the setup. However when I configure the android app Nextcloud to connect to the container directly via http it can exchange data. When I configure the android app to connect via https (which makes use of my reverse proxy) the app hangs after having supplied the credentials and pressing the “Zugriff gewähren” Button the next screen is never shown. (“Zugriff gewähren” means “Approve access”).

There is no strange request showing up in the reverse-proxie’s logs. So something is missing and I cannot tell what. Hence my question how to verify if a reverse proxy is setup correctly. This could be of benefit for users regardless which reverse proxy they decide to use, or even if they want to test the nextcloud installation directly.

At the same time I am suffering Nextcloud only displays a white screen · Issue #1454 · nextcloud/docker · GitHub, but this problem occurs regardless whether I turn my browser to the nextcloud container or the reverse proxy - so I guess it has a different root cause.

Update:
I was able to further investigate on the white screen issue and was able to fix it with a line in the reverse proxy configuration. It acts as workaround for the root cause there.

But it does not fix the behaviour for the android app. So I am still searching for a way to verify the correct reverse proxy setup…