• Настройка Nextcloud за реверсивным Nginx proxy

 #10645   IgorA100
 19 авг 2022, 13:28
В config.php необходимо добавить строки:
Код: Выделить всё'forcessl' => true,
'overwriteprotocol' => 'https',

Иначе в некоторых моментах получите в nextcloud ошибку
csrf check failed


Подобное обсуждение: https://github.com/nextcloud/server/issues/17065
Решение: https://github.com/nextcloud/server/iss ... -274376615
 #10799   IgorA100
 19 мар 2025, 15:45
Nextcloud не дружит с mod_rpaf на Apache 2.4 и его требуется обязательно отключить
Код: Выделить всёa2dismod rpaf

А так-же обязательно включить remoteip
Код: Выделить всёa2enconf remoteip

Далее в конфиге прописываем:
Код: Выделить всё# cat /etc/apache2/conf.d/remoteip.conf
#RemoteIPHeader X-Real-IP
#RemoteIPHeader X-Client-IP
RemoteIPHeader X-Forwarded-For
#RemoteIPTrustedProxy IntIP_reverse_nginx_proxy ExtIP_reverse_nginx_proxy
#RemoteIPInternalProxy IntIP_reverse_nginx_proxy ExtIP_reverse_nginx_proxy
#RemoteIPInternalProxy 127.0.0.1
RemoteIPInternalProxy IntIP_reverse_nginx_proxy


И рестарт апача
 #10841   IgorA100
 02 дек 2025, 23:51
Интеграция с RoundCube

При появлении ошибки:
RoundCube Wrapper for Nextcloud
Unable to login into Roundcube, there are login errors. Please check your personal Roundcube settings. Maybe a re-login to Nextcloud helps. Otherwise contact your system administrator.

и присутствии в логах:
Код: Выделить всё/var/www/nextcloud/apps/mail_roundcube/lib/Service/AuthRoundCube.php:477: OCA\RoundCube\Service\AuthRoundCube::sendRequest(): Opening url 'https://xx.host.com/roundcube//?_task=mail' failed with the following HTTP Status Code: '200'. Curl status: 'Invalid HTTP header field was received: frame type: 1, stream: 1, name: [upgrade], value: [h2]' (92).

Необходимо в конфиг NGINX добавить строку:
Код: Выделить всёproxy_hide_header Upgrade;

Т.е. в итоге конфиг NGINX будет примерно такой:
Код: Выделить всёserver {
    listen 91.240.208.87:80;
    server_name www.cloud.host.com cloud.host.com;

    include /etc/nginx/conf.d/letsencrypt.cnf;

    location / {
        return 301 https://cloud.host.com;
    }
}

server {
    listen 91.240.208.87:443 ssl http2;
    server_name www.cloud.host.com cloud.host.com;
    access_log /var/log/nginx/cloud.host.com/cloud.host.com-access.log;
    error_log /var/log/nginx/cloud.host.com/cloud.host.com-error.log;
    include /etc/nginx/conf.d/letsencrypt.cnf;


    ssl_certificate /etc/letsencrypt/live/office.host.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/office.host.com/privkey.pem;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    #ssl_dhparam /etc/ssl/certs/dhparam.pem;
    ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;

    client_max_body_size 20000M; #Для загрузки больших файлов в облако.

    location / {
        proxy_pass https://192.168.111.160$request_uri;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_hide_header Upgrade;
        proxy_read_timeout 10800; #ТРИ часа
        proxy_send_timeout 10800; #ТРИ часа
        proxy_connect_timeout 10800; #ТРИ часа
        proxy_redirect off; #Иначе могу быть проблемы с зацикливанием!
    }
}