0

Okay, I have 2 servers, one frontend on 192.168.1.100 running nginx, one backend on 192.168.1.151 running apache2. I have nextcloud running on port 80 on the backend server, and I want to proxy to it from my frontend server running https on 443. I'm having some trouble configuring it correctly.

I've tried several configs, and this config is the closest I can get. Here is my nginx location directive:

 location /nextcloud/ {
            proxy_pass http://192.168.1.151:80/nextcloud/;
            proxy_read_timeout    90;
            proxy_connect_timeout 90;
            proxy_redirect        off;

            proxy_set_header      X-Real-IP $remote_addr;
            proxy_set_header      X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header      X-Forwarded-Proto https;
            proxy_set_header      X-Forwarded-Port 443;
            proxy_set_header      Host $host;
    }

Here is my nextcloud config.php file:

    'trusted_domains' =>
  array (
    0 => '192.168.1.151'        ,
    1 => '192.168.1.100'        ,
    2 => '*******.******.org' ,
  ),
  'datadirectory' => '/var/www/nextcloud/data/',
  'overwrite.cli.url' => 'https://********.*********.org/nextcloud/',

When I attempt to use the URL, I do get the nextcloud login prompt, but no formatting (I assume this has something to do with https vs http?) Here is a picture of what I get:

nextcloud_error

I have pretty much the same issue with GOGS (Git on Go). I have accomplished this setup using apache2 on a single server (not multiple IPs) but can't seem to get it working with nginx and seperate IP's.

EDIT: Should have added my chrome console log. As I suspected, it is full of 404 errors for things like: https://*******.*******.org/nextcloud/core/js/login.js?v=49006b299079b9bc3c4fcdf3d018d44a

I can easily find this file at /var/www/nextcloud/core/js/login.js, so the file most certainly exists. Any ideas?

deranjer
  • 181
  • 1
  • 6

1 Answers1

0

The main part missing from my config was proxy_redirect http:// https://; This would redirect all of the http traffic to https without any issues. With a few tweaks here and there to get it running a little better, this is my current working config:

 location ^~ /nextcloud/ {
            proxy_pass http://192.168.1.151/nextcloud/;
            proxy_redirect  http:// https://;

            proxy_set_header      X-Real-IP $remote_addr;
            proxy_set_header      X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header      X-Forwarded-Proto $scheme;
            proxy_set_header      Host $host:$server_port;
    }
deranjer
  • 181
  • 1
  • 6