Nextcloud and Wordpress behind a Reverse NGINX Proxy with locations

Hey Guys,

i really strugelling getting my Nextcloud and Wordpress Container running behind a reverse NGINX proxy using locations. My reverse proxy working fine when i use location /

but when i use different locations like /nextcloud and /wordpress to redirect traffic on one ip address to the applications it doesnt work .

I tried a lot out of the internet last 2 days but nothing worked out from blank screens over can’t access to page not found in wordpress etc.

Maybe someone have running a wordpress and/or nextcloud container behind a reverse proxy with a different location and can post me how he done the configuration in the applications because i rly think the problem is in the application configuration ?!

Can you share how it is related to Docker? Isn’t it just about Nginx configuration? Either way, there is not much to say without error messages and nginx configs.

GUI web apps usually don’t like to be placed under a path, as they return absolute paths for redirect, scripts and images, which won’t work anymore.

Wordpress will always redirect you to the original URL it was installed to, at least it’s one of the apps you can update the domain / ”base path” to make it run under a different URL. Not sure about nextcloud.

Usually you would use an own sub-domain for every service.


thx for your reply . I’m using docker container for rapid Application supply . My setup is working so far . I can assign Applications to static IP addresses rapidly ( using ansible to do so ) but of course i could do it either with docker-compose.

My reverse proxy is working under / location . But under different locations its not working .

My nginx config looks like this:

server {
    server_name localhost;
    large_client_header_buffers 4 16k;

    location /nc {
    proxy_set_header  Host $host;
    proxy_set_header  X-Real-IP $remote_addr;
    proxy_set_header  X-Forwarded-Proto http;
    proxy_set_header  X-Forwarded-Host $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;

    location /.well-known/carddav {
    return 301 $scheme://$host/remote.php/dav;

    location /.well-known/caldav {
    return 301 $scheme://$host/remote.php/dav;

    listen [::]:80;
    listen 80; 


Page not found

The page could not be found on the server or you may not be allowed to view it.

Back to Nextcloud

Nextcloud – a safe home for all your data

Applications responding with page not found . I tried to change the path in wordpress even either but same story page not found.

I changed and tried a lot in nextcloud config.php using nextcloud behind a proxy Reverse proxy — Nextcloud latest Administration Manual latest documentation

Proxy configuration looks like this atm:

trusted_proxies' => 
  array (
    0 => '',
    1 => 'localhost',
    2 => '*',
  'overwritehost' => '',
  'overwriteprotocol' => 'http',
  'overwritewebroot' => '/nc',

Maybe ur right and its just possible behind a subdomain …

What is Is it the IP of the host or the container?

Quote from the nginx documentation

If the address is specified without a URI, or it is not possible to determine the part of URI to be replaced, the full request URI is passed

Your config is

    location /nc {
      # ...

So you will get Unless you have the application under that path, it won’t work. Try with a trailing slash

1 Like

Hey container is listing on port 8080 and host us nginx listing on port 80

THX Man that it was :slight_smile: such a small misstage . I tried hours on configure the application :slight_smile:

I’m glad I could help. Next time you will know that when something doesn’t work in a container, the problem is often not Docker, but the application configuration in the container :slight_smile:

PS:: I removed the quote from your message, since you quoted my entire post and it was also broken.

1 Like