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?