# Nextcloud warning of reverse proxy and HTTPS

**URL:** <https://help.nextcloud.com/t/nextcloud-warning-of-reverse-proxy-and-https/198236>\
**Category:** ℹ️ Support\
**Tags:** reverseproxy, docker, nc29, nginx, setup\_warning\
**Created:** [July 16, 2024, 1:28pm UTC](https://help.nextcloud.com/t/nextcloud-warning-of-reverse-proxy-and-https/198236 "2024-07-16T13:28:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylar](https://help.nextcloud.com/letter_avatar/sylar/32/6_449c533f586939b6e5f246632a46421f.png) [@sylar](https://help.nextcloud.com/u/sylar)\
**Post date:** [July 16, 2024, 1:28pm UTC](https://help.nextcloud.com/t/nextcloud-warning-of-reverse-proxy-and-https/198236/1 "2024-07-16T13:28:33Z")

</div>

Hello, forgive my bad English, it is not my first language.  
I don’t know if anyone else has faced the problem I have but I at least wanted to ask.  
You see, I installed Nextcloud in a docker container and used nginx reverse proxy with the software Cloud Panel to be able to access it from the Internet. Everything worked well.  
But I noticed once I started using Nextcloud that the “Security” section was throwing me warning messages. Specifically, I am concerned about these two messages:

> The reverse proxy header configuration is incorrect. This is a security issue and can allow an attacker to spoof their IP address as visible to the Nextcloud. For more details see the documentation ↗.

> Accessing site insecurely via HTTP. You are strongly advised to set up your server to require HTTPS instead. Without it some important web functionality like “copy to clipboard” or “service workers” will not work! For more details see the documentation ↗.

I think this is something to do with Nginx and the specific configuration it has with Cloud Panel. This would be the conf:

```auto
server {
  listen 80;
  listen [::]:80;
  listen 443 quic;
  listen 443 ssl;
  listen [::]:443 quic;
  listen [::]:443 ssl;
  http2 on;
  http3 off;
  {{ssl_certificate_key}}
  {{ssl_certificate}}
  server_name nextcloud.ouroboroslabs.eu;
  {{root}}

  {{nginx_access_log}}
  {{nginx_error_log}}
  if ($scheme != "https") {
    rewrite ^ https://$host$request_uri permanent;
  }
  location @reverse_proxy {
    proxy_pass {{reverse_proxy_url}};
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $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;
    proxy_set_header Host $host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_pass_request_headers on;
    proxy_max_temp_file_size 0;
    proxy_connect_timeout 900;
    proxy_send_timeout 900;
    proxy_read_timeout 900;
    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;
    proxy_temp_file_write_size 256k;
  }

  {{settings}}

  include /etc/nginx/global_settings;

  add_header Cache-Control no-transform;

  index index.html;

  location ^~ /.well-known {
    auth_basic off;
    allow all;
    try_files $uri @reverse_proxy;
  }

  location / {
    try_files $uri @reverse_proxy;
  }
} 

```

I would have to modify or add something there, right?  
But I have no idea what it could be.  
The docker compose:

```auto
volumes:
  nextcloud:
  db:

services:
  db:
    image: mariadb:10.11
    restart: always
    command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
    volumes:
      - /srv/dev-disk-by-uuid-3f6dc867-2449-4511-a9a0-695590711524/Docker_datos/db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=XXXXXXXX
      - MYSQL_PASSWORD=XXXXXXXX
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud
    restart: always
    ports:
      - 6872:80
    links:
      - db
    volumes:
      - /srv/dev-disk-by-uuid-3f6dc867-2449-4511-a9a0-695590711524/Docker_datos/nextcloud:/var/www/html
    environment:
      - MYSQL_PASSWORD=XXXXXXXX
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db
      - TZ=Europe/Madrid

```

The “occ config:list system” result (man, achieving this was difficult for me.):

```auto
{
    "system": {
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "upgrade.disable-web": true,
        "instanceid": " ***REMOVED SENSITIVE VALUE***",
        "passwordsalt": " ***REMOVED SENSITIVE VALUE***",
        "secret": " ***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "nextcloud.ouroboroslabs.eu"
        ],
        "datadirectory": " ***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "29.0.3.4",
        "overwrite.cli.url": "http:\/\/nextcloud.ouroboroslabs.eu",
        "dbname": " ***REMOVED SENSITIVE VALUE***",
        "dbhost": " ***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": " ***REMOVED SENSITIVE VALUE***",
        "dbpassword": " ***REMOVED SENSITIVE VALUE***",
        "installed": true
    }
}

```

* * *

Nextcloud version: _29.0.3_  
PHP version : _8.2.21_  
Nginx version: _1.26.1_

---

<div class="post-metadata">

**Author:** ![jtr](https://help.nextcloud.com/letter_avatar/jtr/32/6_449c533f586939b6e5f246632a46421f.png) [@jtr](https://help.nextcloud.com/u/jtr)\
**Post date:** [July 16, 2024, 1:32pm UTC](https://help.nextcloud.com/t/nextcloud-warning-of-reverse-proxy-and-https/198236/2 "2024-07-16T13:32:42Z")

</div>

Please post your Docker Compose file and your Nextcloud Server config (e.g. `config.php` or preferably output of `occ config:list system`).

---

<div class="post-metadata">

**Author:** ![sylar](https://help.nextcloud.com/letter_avatar/sylar/32/6_449c533f586939b6e5f246632a46421f.png) [@sylar](https://help.nextcloud.com/u/sylar)\
**Post date:** [July 16, 2024, 3:16pm UTC](https://help.nextcloud.com/t/nextcloud-warning-of-reverse-proxy-and-https/198236/3 "2024-07-16T15:16:03Z")

</div>

I have updated my first post with the configurations you asked for.

---

<div class="post-metadata">

**Author:** ![jtr](https://help.nextcloud.com/letter_avatar/jtr/32/6_449c533f586939b6e5f246632a46421f.png) [@jtr](https://help.nextcloud.com/u/jtr)\
**Post date:** [July 16, 2024, 8:37pm UTC](https://help.nextcloud.com/t/nextcloud-warning-of-reverse-proxy-and-https/198236/4 "2024-07-16T20:37:05Z")

</div>

So from the looks of it your reverse proxy is in a separate stack or maybe even a different server somewhere?

Couple things stand out:

- Configure your `trusted_proxies` with the IP address or CIDR IP subnet of your reverse proxy. You can either do directly in your `config.php`[1] or, since you’re using that Docker image, you could do it via an environment variable in your Compose file[2]
- You may need to set the `overwrite*` parameters to get all the URL handling correct[3][4]. Particularly `overwriteprotocol` (`https`) and `overwrite.cli.url`. Those can also be set via Docker environment variables if so desired.

[1] [Configuration Parameters — Nextcloud latest Administration Manual latest documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#trusted-proxies)  
[2] [GitHub - nextcloud/docker: ⛴ Docker image of Nextcloud](https://github.com/nextcloud/docker/?tab=readme-ov-file#using-the-apache-image-behind-a-reverse-proxy-and-auto-configure-server-host-and-protocol)  
[3] [Reverse proxy — Nextcloud latest Administration Manual latest documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/reverse_proxy_configuration.html#overwrite-parameters)  
[4] [Configuration Parameters — Nextcloud latest Administration Manual latest documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#overwritehost)

---

<div class="post-metadata">

**Author:** ![sylar](https://help.nextcloud.com/letter_avatar/sylar/32/6_449c533f586939b6e5f246632a46421f.png) [@sylar](https://help.nextcloud.com/u/sylar)\
**Post date:** [July 16, 2024, 8:54pm UTC](https://help.nextcloud.com/t/nextcloud-warning-of-reverse-proxy-and-https/198236/5 "2024-07-16T20:54:48Z")

</div>

> [@jtr](#):
>
> So from the looks of it your reverse proxy is in a separate stack or maybe even a different server somewhere?

You’re right. Actually, my reverse proxy and my Nextcloud are on separate virtual machines.  
Sorry for not mentioning that information.  
I will read the links you have passed and see if I can solve that problem with them. Thank you.

---

<div class="post-metadata">

**Author:** ![sylar](https://help.nextcloud.com/letter_avatar/sylar/32/6_449c533f586939b6e5f246632a46421f.png) [@sylar](https://help.nextcloud.com/u/sylar)\
**Post date:** [July 16, 2024, 9:49pm UTC](https://help.nextcloud.com/t/nextcloud-warning-of-reverse-proxy-and-https/198236/6 "2024-07-16T21:49:47Z")

</div>

Thanks a lot. In the end, the solutions you provided solved the error messages I was receiving. In my docker compose I added the following parameters:

```auto
      - TRUSTED_PROXIES=192.168.1.134
      - OVERWRITEPROTOCOL=https

```

And that did the trick.

---

<div class="post-metadata">

**Author:** ![system](https://help.nextcloud.com/user_avatar/help.nextcloud.com/system/32/29333_2.png) [@system](https://help.nextcloud.com/u/system)\
**Post date:** [July 24, 2024, 9:50pm UTC](https://help.nextcloud.com/t/nextcloud-warning-of-reverse-proxy-and-https/198236/7 "2024-07-24T21:50:38Z")

</div>

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.
