title: 502 Bad Gateway Error on Nextcloud Docker Container proxied through Subdomain on Nginx Webserver
body: <p>I am running an Nginx Webserver on my Raspberry Pi 4. I am trying to configure a reverse proxy on  subdomain to a Nextcloud Docker container. However I am getting a 502 Bad Gateway error when I try to visit this container in my browser. I have made sure to generate an SSL certificate for the subdomain I am trying to server Nextcloud over.</p>
  <p>This is what the server block for my subdomain looks like:</p>
  <pre><code>server {
         listen 443 ssl;
         server_name subdomain.domain.tld;
         ssl_certificate /pathtokey/subdomain.domain.tld/fullchain.pem;
         ssl_certificate_key /pathtokey/subdomain.domain.tld/privkey;
         location / {
                  proxy_pass https://127.0.0.1:9000/;
                  proxy_ssl_server_name on;
         }
  }
  </code></pre>
  <p>And this is what my docker-compose.yml file for Nextcloud looks like:</p>
  <pre><code>version: '2'
  
  volumes:
    nextcloud:
    db:
  
  services:
    db:
      image: linuxserver/mariadb
     # command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
      restart: always
      volumes:
        - db:/var/lib/mysql
      environment:
        - MYSQL_ROOT_PASSWORD=&lt;rootPassword&gt;
        - MYSQL_PASSWORD=&lt;mysqlPassword&gt;
        - MYSQL_DATABASE=nextcloud
        - MYSQL_USER=nextcloud
  
    app:
      image: nextcloud:fpm
      ports:
        - 127.0.0.1:9000:9000
      links:
        - db
      volumes:
        - /mnt/hdd/nextcloud:/var/www/html
      restart: always
  </code></pre>
  <p>After changing the .yml file, I make sure to run docker-compose up -d.
  After changing nginx.conf file I run sudo systemctl restart nginx. I have also run sudo nginx -t.</p>
  <pre><code>nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  nginx: configuration file /etc/nginx/nginx.conf test is successful
  </code></pre>
  <p>I am not sure where my mistake is in these configurations. I would appreciate any advice on how to fix this.</p>