Nextcloud Behind Nginx reverseproxy and Apache backend webserver

#1

Hello,

I try to coinfigure my Nextcloud instance with a Nginx reverseproxy and apache like back end server.

My apache server have a wrong GET request:

IP of my Nginx Server - - [24/Apr/2019:10:51:57 +0200] “GET /nextcloudindex.php/login HTTP/1.0” 302 -

And in my firefox I have a message dispaly ther is a wrong redirection.

I have read lot of subject in the forum with proxy problem but I don’t find a solution.

I think it’s a problem of configuration but I don’t know if is the Nextcloud config file or my Nginx.

IP Nginx: 37.37.37.37
IP Apache: 47.47.47.47
DNS entry for my nextcloud: https://cloud.tld.fr

My conf Nginx:

> server {
>     server_name cloud.tld.fr;
> 
> 
>     location / {
>         proxy_pass http://37.37.37.37;
>         proxy_set_header Host $host;
>         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;
>     }
> 
>     listen 443 ssl; # managed by Certbot
>     ssl_certificate /etc/letsencrypt/live/cloud.tld.fr/fullchain.pem; # managed by Certbot
>     ssl_certificate_key /etc/letsencrypt/live/cloud.tld.fr/privkey.pem; # managed by Certbot
>     include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
>     ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
> 
> }

My conf Apache:

> <VirtualHost *:80>
> ServerAdmin admin@example.com
> DocumentRoot "/var/www/html/nextcloud/"
> ServerName cloud.tld.fr
> <Directory "/var/www/html/nextcloud/">
> Options MultiViews FollowSymlinks
> 
> AllowOverride All
> Order allow,deny
> Allow from all
> </Directory>
> TransferLog /var/log/apache2/nextcloud_access.log
> ErrorLog /var/log/apache2/nextcloud_error.log
> </VirtualHost>

My config.php Nextcloud

<?php
$CONFIG = array (
  'instanceid' => '',
  'passwordsalt' => ',
  'secret' => '',
  'trusted_domains' =>
  array (
    0 => 'cloud.tld.fr',
  ),
  'datadirectory' => '',
  'dbtype' => 'mysql',
  'version' => '15.0.7.0',
  'overwrite.cli.url' => 'https://cloud.tld.fr',
  'dbname' => '',
  'dbhost' => '',
  'dbport' => '',
  'dbtableprefix' => '',
  'dbuser' => '',
  'dbpassword' => '',
  'installed' => true,
  'updater.secret' => '',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'mysql.utf8mb4' => true,
  'overwritehost'     => '',
  'trusted_proxies'   => ['37.37.37.37'],
  'overwriteprotocol' => 'https',
  'overwritecondaddr' => '^37\.37\.37\.37$',
);

Thanks for the support.

(IP and DNS are not the real… It’s normal)

#2

Have you seen the existing postings around the requested configuration?

https://help.nextcloud.com/search?q=nginx%20apache%20reverse%20proxy

#3

Yes, but nothing to help my case.

I think the probleme is between nginx and apache but I don’t know if it’s a bad conf of nextcloud and a bad interpretation of redirection.

For me when the get request arrived in my apache server a “/” is missed between the necloud folder and the login.php page.

I have this request in my apache:
GET /nextcloudindex.php/login

And for me i ned this request:
GET /nextcloud/index.php/login

But why the trailslash is missing ??? Good question

#4

Finally I find the solution…

It was a bad configuration of Nginx (probably after many test…)

Thanks for the help.

Have a good day.

1 Like
#5

Unfortunately my problem is not resolved but is different from the first.

Now when I try to call my cloud with this web adress: http://cloud.tld.fr

I have this answer:
https://cloud.tld.fr/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/nextcloud/

And if I F5 the nextcloud login page arrived and I can manage my account etc…

If I write this : https://cloud.tld.fr/index.php/login I have no pronblem

Any solution ?