以下部署过程,均在 Ubuntu 18.04 服务器下以 root 用户执行为例。
部署 Seafile
安装 apache cas 认证模块
apt-get install libapache2-mod-auth-cas
更改配置
-
/etc/apache2/mods-enabled/auth_cas.conf
CASCookiePath /var/cache/httpd/mod_auth_cas/
CASLoginURL https://your.cas-server.com/cas/login
CASValidateURL https://your.cas-server.com/cas/serviceValidate
-
/etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
Alias /media /home/user/haiwen/seafile-server-latest/seahub/media
RewriteEngine On
<Location /media>
Require all granted
</Location>
<Location /sso>
AuthType CAS
Require valid-user
CASAuthNHeader remote-user
</Location>
# seafile fileserver
ProxyPass /seafhttp http://127.0.0.1:8082
ProxyPassReverse /seafhttp http://127.0.0.1:8082
RewriteRule ^/seafhttp - [QSA,L]
# seahub
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8000/
ProxyPassReverse / http://127.0.0.1:8000/
</VirtualHost>
-
/opt/seafile/conf/seahub_settings.py
ENABLE_REMOTE_USER_AUTHENTICATION = True
REMOTE_USER_DOMAIN = 'your.seafile-domain.com'
重启服务
重启 apache
systemctl restart apache2
重启 Seahub
cd /opt/seafile/seafile-server-latest/
./seahub.sh restart
调试
如果登录不成功,请检查 HTTP 请求中是否有
HTTP_REMOTE_USER
头部,调试方法如下:
seahub_settings.py 中增加以下配置
DEBUG = True
重启 Seahub
cd /opt/seafile/seafile-server-latest/
./seahub.sh restart
再次登录测试。