dootask
dootask copied to clipboard
文件链接生成问题
在文件中生成的链接地址与访问地址不一致,如下图。是通过nginx反向代理dootask的http web界面,然后再nginx中跳转至https,但是生成的链接只有http没有https。
你是不是还有一层https,请注意做相关强转
你是不是还有一层https,请注意做相关强转
你说的强转具体指什么,我现在也是相同的问题,dootask本地是在80端口启动的,通过https访问代理服务器的地址,但是生成的文件链接都是http开头的 我翻了一下源码,发现生成的分享链接是调用了这个方法,这里读取的是Server_Port,是不是应该改成读取X-Forwarded-Proto直接获取协议或者根据X-Forwarded-Port来判断 https://github.com/kuaifan/dootask/blob/684bf12a5ce54f6195166b950f109f79318eae21/app/Module/Base.php#L842-L846
你是不是还有一层https,请注意做相关强转
你说的强转具体指什么,我现在也是相同的问题,dootask本地是在80端口启动的,通过https访问代理服务器的地址,但是生成的文件链接都是http开头的 我翻了一下源码,发现生成的分享链接是调用了这个方法,这里读取的是Server_Port,是不是应该改成读取X-Forwarded-Proto直接获取协议或者根据X-Forwarded-Port来判断
Lines 842 to 846 in 684bf12
public static function getSchemeAndHost() { $scheme = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://'; return $scheme.($_SERVER['HTTP_HOST'] ?? ''); }
这是我更改后的部分Nginx的配置。其中监听的80就是强转至下面的443端口。 server { listen 80; server_name domain.com; # 自行修改成你的域名 return 301 https://$server_name$request_uri; } listen 443 ssl http2; server_name domain.com;
ssl_certificate ***.pem;
ssl_certificate_key ***.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256';
# location / {
# root html;
# index index.html index.htm;
# }
location / {
proxy_pass http://localhost/;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}