透視圖在什么網(wǎng)站上可以做企業(yè)網(wǎng)站設(shè)計(jì)欣賞
參考地址
Workerman開啟ssl方法如下-遇見你與你分享
準(zhǔn)備工作:
1、Workerman版本不小于3.3.7
2、PHP安裝了openssl擴(kuò)展
3、已經(jīng)申請(qǐng)了證書(pem/crt文件及key文件)放在了/etc/nginx/conf.d/ssl下
4、配置文件
?location /wss {
? ? proxy_set_header? Host $host;
? ? proxy_set_header? X-Real-IP? $remote_addr;
? ? proxy_set_header? X-Forwarded-For $proxy_add_x_forwarded_for;
? ? proxy_set_header? X-Forwarded-Proto? ?$scheme;
? ? proxy_pass? ? ? ? http://127.0.0.1:9001/wss;
? ??
? ? # 關(guān)鍵配置 start
? ? proxy_http_version 1.1;
? ? proxy_set_header Upgrade $http_upgrade;
? ? proxy_set_header Connection "upgrade";
? ? # 關(guān)鍵配置 end
}? ? ?
代碼:
<?phpuse?Workerman\Worker;use?Workerman\Connection\TcpConnection;require_once?__DIR__?.?'/vendor/autoload.php';//?證書最好是申請(qǐng)的證書$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,'allow_self_signed'?=>?true,?//如果是自簽名證書需要開啟此選項(xiàng)));//?這里設(shè)置的是websocket協(xié)議,也可以http協(xié)議或者其它協(xié)議$worker?=?new?Worker('websocket://0.0.0.0:443',?$context);//?設(shè)置transport開啟ssl$worker->transport?=?'ssl';$worker->onMessage?=?function(TcpConnection?$con,?$msg)?{$con->send('ok');};Worker::runAll();
Workerman開啟服務(wù)器名稱指示?SNI(Server Name Indication)
可實(shí)現(xiàn)在同一IP、端口情況下,綁定多個(gè)證書。
合并證書.pem和.key文件:
將每個(gè)證書的.pem和對(duì)應(yīng)的.key文件內(nèi)容合并,將.key文件內(nèi)容添加到.pem文件結(jié)尾。(若.pem文件內(nèi)已包含私鑰,則可忽略。)
請(qǐng)注意是單個(gè)證書,不是把所有證書復(fù)制到一個(gè)文件
例如host1.com.pem合并后的pem文件內(nèi)容大概如下:
-----BEGIN?CERTIFICATE-----MIIGXTCBA...-----END?CERTIFICATE----------BEGIN?CERTIFICATE-----MIIFBzCCA...-----END?CERTIFICATE----------BEGIN?RSA?PRIVATE?KEY-----MIIEowIBAA....-----END?RSA?PRIVATE?KEY-----
代碼:
<?phpuse?Workerman\Worker;use?Workerman\Connection\TcpConnection;require_once?__DIR__?.?'/vendor/autoload.php';$context?=?array('ssl'?=>?array('SNI_enabled'?=>?true,?//?開啟SNI'SNI_server_certs'?=>?[?//?設(shè)置多個(gè)證書'host1.com'?=>?'/path/host1.com.pem',?//?證書1?服務(wù)器根目錄'host2.com'?=>?'/path/host2.com.pem',?//?證書2??服務(wù)器根目錄],'local_cert'?=>?'/path/default.com.pem',?//?默認(rèn)證書'local_pk'???=>?'/path/default.com.key',));$worker?=?new?Worker('websocket://0.0.0.0:443',?$context);$worker->transport?=?'ssl';$worker->onMessage?=?function(TcpConnection?$con,?$msg)?{$con->send('ok');};Worker::runAll();
代表啟動(dòng)成功