我试图让 Seafile 在 nginx 反向代理后面运行。我跟着这个:http ://manual.seafile.com/deploy/deploy_with_nginx.html以及这个: http: //manual.seafile.com/deploy/https_with_nginx.html。
我的配置如下:
- 为虚拟主机“cloud.mydomain.tld”运行的 Nginx
- Seafile 和 Seahub(在 fastcgi 模式下)都在其默认端口上运行
我的 seahub_settings.py 看起来像这样:
HTTP_SERVER_ROOT = 'https://cloud.mydomain.tld/seafhttp' -- I added this to try it FILE_SERVER_ROOT = 'https://cloud.mydomain.tld/seafhttp' SECRET_KEY = "12345678-1234-1234-1234-1234567890123456" DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'seahub-db', 'USER': 'seafile', 'PASSWORD': 'mypassword', 'HOST': '127.0.0.1', 'PORT': '3306', 'OPTIONS': { 'init_command': 'SET storage_engine=INNODB', } } }
我的 nginx 配置:
### Cloud ### # No-SSL redirect server { listen 80; server_name cloud.mydomain.tld; return 301 https://$server_name$request_uri; } # SSL server { listen 443 ssl; server_name cloud.mydomain.tld; ssl_certificate /etc/letsencrypt/live/cloud.mydomain.tld/cert.pem; ssl_certificate_key /etc/letsencrypt/live/cloud.mydomain.tld/privkey.pem; 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; 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 http://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; } location /media { root /home/cloud/seafile-server-latest/seahub; } }
- 这应该是最重要的。
所以现在,当我删除我的旧 seahub_settings.pyc,启动 seahub(当然是在 fastcgi 模式下),将浏览器指向我的库并尝试上传一些东西时,我在 F12 开发者控制台中收到以下错误消息:
main.ad03aea1e16e.js:215 Mixed Content: The page at 'https://cloud.mydomain.tld/#my-libs/lib/12345678-1234-1234-1234-123456789012' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://cloud.mydomain.tld:8082/upload-aj/12345678-1234-1234-1234-123456789012'. This request has been blocked; the content must be served over HTTPS.
send @ main.ad03aea1e16e.js:215
这意味着,seahub 仍在尝试连接到“旧”上传服务,这当然不再起作用。直到现在,我还没有找到任何解决这个问题的方法。