Avoid change in host URL when proxied server has an automatic redirect. (Nginx)

Viewed 10

I wasn't sure how to name the topic, hopefully that kind of make sense.

I am currently building a NAS using TrueNAS with NextCloud integrated in it. I want one domain name to point either to the NAS dashboard or the NextCloud interface depending on the end of the URL eg. www.example.com/nas points to the dashboard and www.example.com/cloud points to the NextCloud interface.

I have been able to set Nginx to proxy to one using the base domain name, as well as pointing to either the NAS or Cloud depending on the end of the URL. The issue though comes from the redirects within the NAS and the Cloud. When accessing the NAS dashboard by entering xxx.xxx.xxx.xxx the IP is automatically changed to xxx.xxx.xxx.xxx/ui, this also happens when proxied through Nginx. eg. www.example.com/nas becomes www.example.com/ui which Nginx doesn't understand. The same happens with NextCloud IP.

What I would like is either to make the redirect "invisible" (eg. www.example.com/nas stays as is and never includes the requests from the proxy address) or to forward the proxy's requests to the URL (eg. www.example.com/nas becomes www.example.com/nas/ui when the proxied server redirects it) which would be my prefered way.

I tried a few things with different definition of locate {} in the .conf but I could not get it to work.

0 Answers
Related