Seafile Pro Unable to upload 502 Bad Gateway

I’ve checked many similiar topics and have not had any luck so I appreciate any help!

I’m running the docker instructions found here on Ubuntu 18.04 and getting the following error.

nginx configuration

log_format seafileformat '$http_x_forwarded_for $remote_addr [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $upstream_response_time';



server {

    server_name domain.net;



    proxy_set_header X-Forwarded-For $remote_addr;



    location / {

         proxy_pass         http://127.0.0.1:8000;

         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-Host $server_name;

         proxy_read_timeout  1200s;



         # used for view/edit office file via Office Online Server

         client_max_body_size 0;



         access_log      /var/log/nginx/seahub.access.log seafileformat;

         error_log       /var/log/nginx/seahub.error.log;

    }



# If you are using [FastCGI](http://en.wikipedia.org/wiki/FastCGI),

# which is not recommended, you should use the following config for location `/`.

#

#    location / {

#         fastcgi_pass    127.0.0.1:8000;

#         fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;

#         fastcgi_param   PATH_INFO           $fastcgi_script_name;

#

#         fastcgi_param	 SERVER_PROTOCOL	 $server_protocol;

#         fastcgi_param   QUERY_STRING        $query_string;

#         fastcgi_param   REQUEST_METHOD      $request_method;

#         fastcgi_param   CONTENT_TYPE        $content_type;

#         fastcgi_param   CONTENT_LENGTH      $content_length;

#         fastcgi_param	 SERVER_ADDR         $server_addr;

#         fastcgi_param	 SERVER_PORT         $server_port;

#         fastcgi_param	 SERVER_NAME         $server_name;

#         fastcgi_param   REMOTE_ADDR         $remote_addr;

#     	 fastcgi_read_timeout 36000;

#

#         client_max_body_size 0;

#

#         access_log      /var/log/nginx/seahub.access.log;

#     	 error_log       /var/log/nginx/seahub.error.log;

#    }



    location /seafhttp {

        rewrite ^/seafhttp(.*)$ $1 break;

        proxy_pass https://127.0.0.1:8082;

        client_max_body_size 0;

        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;



        proxy_connect_timeout  36000s;

        proxy_read_timeout  36000s;

        proxy_send_timeout  36000s;



        send_timeout  36000s;



        access_log      /var/log/nginx/seafhttp.access.log seafileformat;

        error_log       /var/log/nginx/seafhttp.error.log;

    }

#    location /media {
#
#        root /home/user/haiwen/seafile-server-latest/seahub;
#
#    }


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/domain.net/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/domain.net/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

}




server {
    if ($host = domain.net) {
        return 301 https://$host$request_uri;
    } # managed by Certbot



    listen 80;

    server_name domain.net;
    return 404; # managed by Certbot


}

seafhttp.error.log

2020/01/13 03:17:25 [error] 15665#15665: *47 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xxx.xx, server: domain.net, request: "POST /seafhttp/upload-aj/eae51e11-99d3-434f-abcc-e61f8a00f74c?ret-json=1 HTTP/1.1", upstream: "https://127.0.0.1:8082/upload-aj/eae51e11-99d3-434f-abcc-e61f8a00f74c?ret-json=1", host: "domain.net", referrer: "https://domain.net/library/ed212d82-d0e2-41e3-bf49-211326af547d/My%20Library/"

seahub.error.log

2020/01/13 00:44:29 [error] 19170#19170: *104 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xx.xxx.xx, server: domain.net, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "domain.net"

docker-compose.yml

version: '2.0'
services:
  db:
    image: mariadb:10.1
    container_name: seafile-mysql
    environment:
      - MYSQL_ROOT_PASSWORD=password # Requested, set the root's password of MySQL service.
      - MYSQL_LOG_CONSOLE=true
    volumes:
      - /opt/seafile-mysql/db:/var/lib/mysql  # Requested, specifies the path to MySQL data persistent store.
    networks:
      - seafile-net

  memcached:
    image: memcached:1.5.6
    container_name: seafile-memcached
    entrypoint: memcached -m 256
    networks:
      - seafile-net

  elasticsearch:
    image: seafileltd/elasticsearch-with-ik:5.6.16
    container_name: seafile-elasticsearch
    environment:
      - discovery.type=single-node
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms1g -Xmx1g"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    mem_limit: 2g
    volumes:
      - /opt/seafile-elasticsearch/data:/usr/share/elasticsearch/data  # Requested, specifies the path to Elasticsearch data persistent store.
    networks:
      - seafile-net
          
  seafile:
    image: docker.seadrive.org/seafileltd/seafile-pro-mc:latest
    container_name: seafile
    ports:
      - "8000:80"
#     - "443:443"  # If https is enabled, cancel the comment.
    volumes:
      - /opt/seafile-data:/shared   # Requested, specifies the path to Seafile data persistent store.
    environment:
      - DB_HOST=db
      - DB_ROOT_PASSWD=password # Requested, the value shuold be root's password of MySQL service.
      - TIME_ZONE=America/Chicago # Optional, default is UTC. Should be uncomment and set to your local time zone.
      - SEAFILE_ADMIN_EMAIL=email # Specifies Seafile admin user, default is 'me@example.com'
      - SEAFILE_ADMIN_PASSWORD=password     # Specifies Seafile admin password, default is 'asecret'
      - SEAFILE_SERVER_LETSENCRYPT=false   # Whether to use https or not
      - SEAFILE_SERVER_HOSTNAME=domain.net # Specifies your host name if https is enabled
    depends_on:
      - db
      - memcached
      - elasticsearch
    networks:
      - seafile-net

networks:
        seafile-net:

ccnet.conf

[General]
USER_NAME = seafile
ID = 596530730e962f7362487ca667894b19e4c73695
NAME = seafile
SERVICE_URL = https://domain.net

[Client]
PORT = 13419

[Database]
ENGINE = mysql
HOST = db
PORT = 3306
USER = seafile
PASSWD = password
DB = ccnet_db
CONNECTION_CHARSET = utf8


[Client]
UNIX_SOCKET = /opt/seafile/ccnet.sock

seahub_settings.py

# -*- coding: utf-8 -*-
SECRET_KEY = "dsffdsafasdfasf"

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'seahub_db',
        'USER': 'seafile',
        'PASSWORD': 'password',
        'HOST': 'db',
        'PORT': '3306'
    }
}


CACHES = {
    'default': {
        'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
        'LOCATION': 'memcached:11211',
    },
    'locmem': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
    },
}
COMPRESS_CACHE_BACKEND = 'locmem'
TIME_ZONE = 'America/Chicago'
FILE_SERVER_ROOT = "https://domain.net/seafhttp"

Is there a better support forum to post this to?

So your nginx rule redirects the traffic to port 8082, but in docker you haven forwarded the port from seafile-mc container?

I’m not sure what this means. I followed the guide pretty much exactly.

Ok this actually isn’t the cause.

But when you’re forwarding to port 8000 on the host FILE_SERVER_ROOT and SERVICE_URL have to contain the port. But it looks like you’re connecting using a different path anyway (port 443 is not forwarded according to your composer file).

Thanks. I’m not sure what to do. or what settings to change.

I changed the following in the docker-compose.yml

        - "4443:443"  # If https is enabled, cancel the comment.
        - SEAFILE_SERVER_LETSENCRYPT=true

The files FILE_SERVER_ROOT and SERVICE_URL are https://domain.net and https://domain.net/seafhttp

I tried adding the port at the end with no luck.

I’m sorry I’m trying to follow the guide but it’s terrible.