0

How can I proxy web applications with url prefix using Nginx or Apache2 in my server?

For example, I run a NextCloud in Docker and I want to access it by https://my-domain.example/nextcloud/, so I use nginx with below config.

 location /nextcloud {
            proxy_pass         http://docker_ip;
            proxy_redirect     off;
            proxy_set_header   Host $host;
        }

Unfortunately, it only can proxy the index and other resources such as js files or css files are 404 not found, because their URL does not contain the prefix /nextcloud.

Previously, I use the apt to install the owncloud which can integrated with Apache2 and I can access it with https://my-domain.example/owncloud/.

I want to know how can I achieve this result when I use docker to run web application?

update

If I use a subdomain, how can I proxy the https to http? When I visit the nextcloud.my-domain.example, it will return a 302 not dound with a http location. How can I make the location become https?

gds
  • 1
  • 1
  • You might have an easier time proxying a subdomain like `nextcloud.my-domain.example`. I'd bet NextCloud is assuming it's running on the root of a FQDN and generates links accordingly. Proxying won't cause those links to get rewritten. – ceejayoz May 30 '18 at 19:29
  • If I use a subdomain, how can I proxy the https to http? When I visit the `nextcloud.my-domain.example/`, it will return a 302 not dound with a **http** location. – gds May 31 '18 at 11:15

0 Answers0