如何讓webserver實(shí)現(xiàn)兩個(gè)功能
1.http訪問自動(dòng)跳轉(zhuǎn)https?
2.http和https可以同時(shí)訪問
use Workerman/Protocols/Http;
Http::header('Location: https://domain.com/xxx');
?
https默認(rèn)是443端口,開啟方法類似
$context = array(
'ssl' => array(
'local_cert' => '/etc/nginx/conf.d/ssl/server.pem', // 也可以是crt文件
'local_pk' => '/etc/nginx/conf.d/ssl/server.key',
'verify_peer' => false,
)
);
// 這里設(shè)置的是websocket協(xié)議,也可以http協(xié)議或者其它協(xié)議
$worker = new WebServer('http://0.0.0.0:443', $context);
// 設(shè)置transport開啟ssl
$worker->transport = 'ssl';