Reverse Proxy with overwritewebroot causing // in urls

I am trying to setup nextcloud behind a nginx reverse proxy (running on another machine) that has ssl on it. While I can get the “interface” to show up, nothing behind the scenes works (file listing fails, contacts never finish loading). When I remove the overwrite settings and connect directly to the server, things load up fine (including contacts), and there is a distinct difference in the logging output

nextcloud-app-1  | 172.16.121.115 - - [05/Sep/2022:22:37:54 +0000] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 200 969 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.115 - - [05/Sep/2022:22:37:54 +0000] "GET /custom_apps/contacts/img/favicon.ico HTTP/1.1" 200 4817 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.115 - - [05/Sep/2022:22:37:54 +0000] "PUT /apps/user_status/heartbeat HTTP/1.1" 200 930 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.115 - - [05/Sep/2022:22:37:54 +0000] "GET /cron.php HTTP/1.1" 200 904 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.115 - - [05/Sep/2022:22:37:54 +0000] "PROPFIND /remote.php/dav/principals/users/ruckjoh1/ HTTP/1.1" 207 1659 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.115 - - [05/Sep/2022:22:37:54 +0000] "PROPFIND /remote.php/dav/addressbooks/users/ruckjoh1/ HTTP/1.1" 207 1641 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.115 - - [05/Sep/2022:22:37:54 +0000] "REPORT /remote.php/dav/addressbooks/users/ruckjoh1/contacts/ HTTP/1.1" 207 881 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.115 - - [05/Sep/2022:22:37:54 +0000] "REPORT /remote.php/dav/addressbooks/users/ruckjoh1/z-app-generated--contactsinteraction--recent/ HTTP/1.1" 207 881 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"

each url starts with a single /

when I put the overwrite* back in place the logging shows this:

nextcloud-app-1  | 172.16.121.101 - - [05/Sep/2022:22:39:45 +0000] "GET //apps/theming/img/core/filetypes/text.svg?v=0 HTTP/1.0" 200 1190 "https://www.silverblazegaming.com/1c9df314/apps/dashboard/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.101 - - [05/Sep/2022:22:39:45 +0000] "GET //ocs/v2.php/apps/weather_status/api/v1/forecast HTTP/1.0" 200 1356 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.101 - - [05/Sep/2022:22:39:50 +0000] "GET //apps/contacts/ HTTP/1.0" 200 21880 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.101 - - [05/Sep/2022:22:39:51 +0000] "GET //css/contacts/28e4-6eed-contacts.css?v=759065f6cd502a79bff417f2ffb8be63-28e407d0-0 HTTP/1.0" 200 3502 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.101 - - [05/Sep/2022:22:39:51 +0000] "GET //custom_apps/contacts/js/contacts-main.js?v=1109ac9f-0 HTTP/1.0" 200 1209045 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.101 - - [05/Sep/2022:22:39:51 +0000] "GET //ocs/v2.php/search/providers?from=%2F1c9df314%2Fapps%2Fcontacts%2F HTTP/1.0" 200 1081 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.101 - - [05/Sep/2022:22:39:51 +0000] "PROPFIND //remote.php/dav/ HTTP/1.0" 500 4059 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.101 - - [05/Sep/2022:22:39:51 +0000] "GET //ocs/v2.php/apps/circles/circles HTTP/1.0" 200 858 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.101 - - [05/Sep/2022:22:39:51 +0000] "GET //ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.0" 200 933 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.101 - - [05/Sep/2022:22:39:51 +0000] "PUT //apps/user_status/heartbeat HTTP/1.0" 200 894 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.101 - - [05/Sep/2022:22:39:51 +0000] "GET //custom_apps/contacts/img/favicon.ico HTTP/1.0" 200 4781 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
nextcloud-app-1  | 172.16.121.101 - - [05/Sep/2022:22:39:51 +0000] "GET //cron.php HTTP/1.0" 200 867 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"

each url with a // at the start.

I cant find any setting that will get rid of that extra /, (I have tried putting an extra / on the overwritewebroot value, tried adding an extra / to the end of the nginx proxy location line, I have even tried to empty the htaccess.RewriteBase value (might not have “reinitialized” things after changing that one…, not really familiar with apache2 mechanics - I tried running
docker exec --user www-data nextcloud-app-1 php occ maintenance:update:htaccess
but that didnt have a noticeable effect - still // after restarting the instance).

In each case the nginx and the nextcloud are running in docker containers on different machines.

The overwrite settings from my config.php are

  'overwritehost' => 'www.silverblazegaming.com',
  'overwriteprotocol' => 'https',
  'overwritewebroot' => '/1c9df314',

and my nginx reverse proxy configuration is (and this machine is accessible as www.silverblazegaming.com - verified access works without nextcloud involvement)

# Nextcloud
location /1c9df314 {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-NginX-Proxy true;
    proxy_pass http: // dockerhost7.silverblazegaming.com:8080/;
    proxy_ssl_session_reuse off;
    proxy_set_header Host $http_host;
    proxy_cache_bypass $http_upgrade;
    proxy_redirect off;
}

every time I made a change I would reimage and restart the docker containers, not sure if anything else needs to be done for changes to take effect.

At this point I will welcome any ideas on what is causing the // when proxied, I havent found anything that will get rid of the extra one.

I put in the extra spacing in the proxy_pass line of the nginx reverse proxy configuration while trying to get around the forum system complaining I had more than 4 links in the posting (that was before I code blocked the log entries which seems to have been that problem.

And also in case is it isnt already clear, the url on the reverse proxy is https://www.silverblazegaming.com/1c9df314 (an instance running a nginx:stable docker image) which is redirecting to http://dockerhost7.silverblazegaming.com:8080 (an instance running the nextcloud:latest docker image).

Resolved - turned out to be rookie error :blush:

Corrected nginx configuration block (I didnt match up a / at the end of the location string while I had one in the proxy_pass redirect url at the end.)

# Nextcloud
location /1c9df314/ {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-NginX-Proxy true;
    proxy_pass http://dockerhost7.silverblazegaming.com:8080/;
    proxy_ssl_session_reuse off;
    proxy_set_header Host $http_host;
    proxy_cache_bypass $http_upgrade;
    proxy_redirect off;
}
2 Likes