CDN中Off loader头的用途是什么?
SSL_OFFLOADED
有什么区别
&安培;
X-Forwarded-Proto
何时使用? 除了上面两种之外还有其他类型吗?
最新回答
- 2019-12-51 #
- 2019-12-52 #
Offloader header and HTTPS server variable are used by Magento 2 to figure out if request is secure (https).
如果您未设置服务器变量HTTPS
fastcgi_param HTTPS on
然后magento检查Offloader标题:
供应商/的magento /框架/应用/请求/ Http.php
public function isSecure() { if ($this->immediateRequestSecure()) { return true; } /* TODO: Untangle Config dependence on Scope, so that this class can be instantiated even if app is not installed MAGETWO-31756 */ // Check if a proxy sent a header indicating an initial secure request $config = $this->objectManager->get('Magento\Framework\App\Config'); $offLoaderHeader = trim( (string)$config->getValue( self::XML_PATH_OFFLOADER_HEADER, ScopeConfigInterface::SCOPE_TYPE_DEFAULT ) ); return $this->initialRequestSecure($offLoaderHeader); } .... protected function initialRequestSecure($offLoaderHeader) { $header = $this->getServer($offLoaderHeader); $httpHeader = $this->getServer('HTTP_' . $offLoaderHeader); return !empty($offLoaderHeader) && (isset($header) && ($header === 'https') || isset($httpHeader) && ($httpHeader === 'https')); }
参见initialRequestSecure函数,如果Offloader标头(或HTTP_ {Offloader标头})设置为https,则请求是安全的。
没有区别. Magento 2中的默认卸载程序头是
X-Forwarded-Proto
,这符合事实上的标准。SSL_OFFLOADED
另一方面,它是Magento 1中的默认卸载程序头,也是Magento 1中流行的Varnish扩展程序Nexcess_Turpentine使用的。基本上,您可以根据需要调用标头,只需要确保SSL终结器发送它.如果你不确定,
X-Forwarded-Proto
可能是正确的value。