1

最近几天,我尝试在安装了 Plesk Onyx 17 的 VPS 上运行带有 MySQL 的当前 Seafile 6.0.5。

如果我按照官方 seafile.com 手册 => https://manual.seafile.com/deploy/deploy_with_nginx.html

我可以从:http:IP_ADRESS:8000 打开 webui。

但是当我添加 NGINX 配置并以 fastcgi 模式启动 seahub 以到达 Seafile 下:https://seafile.mydomain.com (lets-encrypt https) 时,我只看到左上角的 seafile 徽标,一个非工作语言选择器在右上角,并显示一条文字:“抱歉,未找到请求的页面”。

我的日志/seahub_django_request.log:

2016-11-03q 04:51:11,438 [WARNING] django.request:170 get_response Not Found: /index.html
2016-11-03 04:51:13,204 [WARNING] django.request:170 get_response Not Found: /index.html
2016-11-03 04:58:06,150 [WARNING] django.request:170 get_response Not Found: /index.html
...

我的 ccnet.conf:

[General]
USER_NAME = PrivateSeafile
ID = id
NAME = PrivateSeafile
SERVICE_URL = https://seafile.mydomain.com

[Database]
ENGINE = mysql
HOST = 127.0.0.1
PORT = 3306
USER = seafile
PASSWD = pass
DB = ccnet-db
CONNECTION_CHARSET = utf8

我的 seahub_settings.py:

SECRET_KEY = "secret"

FILE_SERVER_ROOT = 'https://seafile.mydomain.com/seafhttp'
#SITE_BASE = 'https://seafile.mydomain.com'
#SITE_ROOT = '/'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'seahub-db',
        'USER': 'seafile',
        'PASSWORD': 'pw',
        'HOST': '127.0.0.1',
        'PORT': '3306'
    }
}

我在 Plesk 中的附加 nginx 设置如下:

server_tokens off;
proxy_set_header X-Forwarded-For $remote_addr;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";

location ~ / {
    if ($scheme = http) {
        return 301 https://$http_host$request_uri?;
    }
    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   HTTPS               on;
    fastcgi_param   HTTP_SCHEME         https;

    access_log      /var/log/nginx/seahub.access.log;
    error_log       /var/log/nginx/seahub.error.log;
    fastcgi_read_timeout 36000;
}

location /seafhttp {
    rewrite ^/seafhttp(.*)$ $1 break;
    proxy_pass https://127.0.0.1:8082;
    client_max_body_size 0;
    proxy_connect_timeout  36000s;
    proxy_read_timeout  36000s;
    proxy_send_timeout  36000s;
    send_timeout  36000s;
    proxy_request_buffering off;
}

location /seafdav {
    fastcgi_pass    127.0.0.1:8080;
    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   HTTPS               on;
    client_max_body_size 0;
    proxy_request_buffering off;

    access_log      /var/log/nginx/seafdav.access.log;
    error_log       /var/log/nginx/seafdav.error.log;
}

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

location /.well-known/acme-challenge {
    root /var/www/vhosts/mydomain.com/seafile.mydomain.com;
}

我希望有人有一个如何解决它的想法。我知道 Plesk 就是这样,因为我使用原始 nginx 多次部署 seafile 并且运行良好。

4

1 回答 1

1

所以我通过为 Plesk Onyx 创建自定义 nginx 虚拟域主机配置来解决它。

为此:

mkdir /usr/local/psa/admin/conf/templates/custom
mkdir /usr/local/psa/admin/conf/templates/custom/domain
cd /usr/local/psa/admin/conf/templates/custom/domain
cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php ./

vim nginxDomainVirtualHost.php

删除或评论以下内容:

location ~ /$ {
    <?php echo $VAR->domain->physicalHosting->proxySettings['directoryIndex'] ?>
}

Plesk 文档说:

生成新的配置文件:通过:

httpdmng --reconfigure-domain YOUR_DOMAIN

但在控制台上响应

找不到命令 httpdmng

因此,只需在 Plesk 中打开您的域 Apace 和 nginx 设置,然后单击确定。

其他 nginx 配置的其他小问题会破坏与本地客户端的同步:

location /seafhttp {
    rewrite ^/seafhttp(.*)$ $1 break;
    proxy_pass https://127.0.0.1:8082;

必须:

location /seafhttp {
    rewrite ^/seafhttp(.*)$ $1 break;
    proxy_pass http://127.0.0.1:8082;

所以只有http而不是https。

希望对其他人有所帮助;)

于 2016-11-09T09:31:05.350 回答