问题描述
使用Nginx反向代理内网的Typecho站点,为了效率内网访问不需要使用https,这样Typecho接收到的请求是http协议的,于是网站内部资源链接被修改成了http
解决方案
定位到解析url依赖\var\Typecho\Request.php
文件中的isSecure()
函数,如下:
/**
* 判断是否为https
*
* @access public
* @return boolean
*/
public static function isSecure()
{
return (!empty($_SERVER['HTTPS']) && 'off' != strtolower($_SERVER['HTTPS']))
|| (!empty($_SERVER['SERVER_PORT']) && 443 == $_SERVER['SERVER_PORT'])
|| (defined('__TYPECHO_SECURE__') && __TYPECHO_SECURE__);
}
然后在config.inc.php
中最上面添加
/** 启用https **/
define('__TYPECHO_SECURE__', true);
无回应:“Typecho反向代理http访问强制启用生成https链接”