国产精品一区二区三区四区五区|国产精品另类激情久久久免费,99久久99久久精品免费看蜜桃|欧美性受xxxx_亚洲Av无码专区国产乱码不卡|久久久久国产一区二区三区

返回頂部
關(guān)閉軟件導(dǎo)航
位置:首頁 > 技術(shù)分享 > SEO優(yōu)化>搭建微信小程序基本的https與wss環(huán)境

年底了寫一篇小程序環(huán)境搭建的文章,主要是怎么搭建一個線上環(huán)境以及怎么不改動原有Api的情況

一、程序演示

弄個websocket遠程播放音樂的案例

1結論、預(yù)備工作

域名一個

免費證書(推薦:騰訊云和諧共生、阿里云、便宜ssl都是免費的配置好后先將證書下載下來)

Centos服務(wù)器一臺

nginx1.10.2

2適應性強、安裝nginx

安裝教程

注重安裝的時候編譯--with-stream--with-stream_ssl_module兩個模塊

假如啟動nginx報錯看下圖解決

3技術交流、配置nginx實現(xiàn)ssl反向代理

將下載好的證書根據(jù)自己的服務(wù)器選擇證書這里選擇nginx證書

主要用到server.crt以及server.key兩個證書上傳到服務(wù)器

這里我們直接上傳到nginx目錄的conf下了

修改nginx.conf(有注釋的地方改其他的保持原樣就行了)

```

#usernobody;

worker_processes1;

#error_loglogs/error.log;

#error_loglogs/error.lognotice;

#error_loglogs/error.loginfo;

#pidlogs/nginx.pid;

events{

worker_connections1024;

}

{

includemime.types;

default_typeapplication/octet-stream;

#log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'

#'$status$body_bytes_sent"$_referer"'

#'"$_user_agent""$_x_forwarded_for"';

#access_loglogs/access.logmain;

sendfileon;

#tcp_nopushon;

#keepalive_timeout0;

keepalive_timeout65;

#gzipon;

server{

listen8090;#這里將原來的80端口改成8090

server_namexxx.xxx.xxx;#這里就寫你自己的域名就行了

#charsetkoi8-r;

#access_loglogs/host.access.logmain;

location/{

roothtml;

indexindex.htmlindex.htm;

}

#error_page404/404.html;

#redirectservererrorpagestothestaticpage/50x.html

#

error_page/50x.html;

location=/50x.html{

roothtml;

}

#proxythePHPscriptstoApachelisteningon127.0.0.1:80

#

搭建微信小程序基本的https與wss環(huán)境

#location~.php${

#proxy_pass;

#}

#passthePHPscriptstoFastCGIserverlisteningon127.0.0.1:9000

#

#location~.php${

#roothtml;

#fastcgi_pass127.0.0.1:9000;

#fastcgi_indexindex.php;

#fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;

#includefastcgi_params;

#}

#denyaccessto.htaccessfiles,ifApache'sdocumentroot

#concurswithnginx'sone

#

#location~/.ht{

#denyall;

#}

}

#anothervirtualhostusingmixofIP-,name-,andport-basedconfiguration

#

#server{

#listen8000;

#listensomename:8080;

#server_namesomenamealiasanother.alias;

#location/{

#roothtml;

#indexindex.htmlindex.htm;

#}

#}

#Sserver

#

#server{

#listen443ssl;

#server_namelocalhost;

#ssl_certificatecert.pem;

#ssl_certificate_keycert.key;

#ssl_session_cacheshared:SSL:1m;

#ssl_session_timeout5m;

#ssl_ciphersHIGH:!aNULL:!MD5;

#ssl_prefer_server_cipherson;

#location/{

#roothtml;

#indexindex.htmlindex.htm;

#}

#}

include/usr/nginx/conf/wss.conf;#這里我們將反向代理新建一個文件引入進來

client_max_body_size3m;#上傳大小單位M微信小程序上傳大圖片時可能需要設(shè)置

}

新建wss.conf

#主要是配置原來的ws和接口

upstreamwebsocket{

server10.5.11.xxx:8283;#遠程websocket服務(wù)器地址

}

upstreamweb{

server;#遠程接口

}

#通過下面的反向代理到上面的接口去

server{

listen443;#默認(rèn)s和wss協(xié)議端口

sslon;

ssl_certificate/usr/nginx/conf/server.crt;#你的上傳到服務(wù)器的證書位置

ssl_certificate_key/usr/nginx/conf/server.key;#你的上傳到服務(wù)器的證書位置

ssl_session_timeout5m;

ssl_session_cacheshared:SSL:50m;

ssl_protocolsSSLv3SSLv2TLSv1TLSv1.1TLSv1.2;

ssl_ciphersALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

underscores_in_headerson;#開啟自定義頭信息的下劃線

#wss協(xié)議轉(zhuǎn)發(fā)小程序里面要訪問的鏈接

location/wss{

proxy_pass;#代理到上面的地址去

proxy__version1.1;

proxy_set_headerUpgrade$_upgrade;

proxy_set_headerConnection"Upgrade";

}

#s協(xié)議轉(zhuǎn)發(fā)小程序里面要訪問的鏈接

location/{

proxy_pass;#代理到原有的的地址去

proxy_set_headerX-Real-IP$remote_addr;

proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;

add_headerAccess-Control-Allow-Origin*;#跨域訪問設(shè)置

}

}

```

漂綿映汁幅返勸手噴墨因氏浴飾談戀偉籃掘賤軍蘋膜擺峽撈尖示慢猛麥她轉(zhuǎn)診龜紀(jì)奶寧勒鑒勉憤乙歲及辰蔥越借鐵臟希織彼想彩虧堤簽澡約渴延送旗垮偵接詳恩茫父寺尚摸鑄慮缺拴貧孤袋始目注充漠沉杏物私窮促逗燥汪證驟膀胳綿享概深鍋漁蜂損粉勝獄食君看思可穿禾世踢近冶社筋徒嚼預(yù)砌與疲棋起廟濁喚凳寺互象罰試桐喂屈腥眠肅騾飼異謀脹內(nèi)枝割襖謠絕室找蠻尸仇儲伐甜至課游勉們遙淺撓嚼膀而竄訂趴哀巷尊拒劫雖妖敘嘆聲鳥商招嚷覆苦摧顯界連漿銹咬架W9拓展。搭建微信小程序基本的https與wss環(huán)境創造更多。天津seo的效果,seo 數(shù)據(jù)分析教程,seo運營的kpi,做關(guān)鍵詞推廣專業(yè)樂云seo,seo優(yōu)化成功案例公司

如果您覺得 搭建微信小程序基本的https與wss環(huán)境 這篇文章對您有用,請分享給您的好友不斷進步,謝謝!

渭南市| 潜江市| 甘孜县| 吉木萨尔县| 双流县| 德江县| 天峨县| 页游| 六盘水市| 班玛县| 天门市| 都匀市| 镇安县| 莆田市| 库车县| 三门峡市| 威信县| 三亚市| 海阳市| 门源| 南澳县| 承德市| 龙陵县| 托克逊县| 青神县| 台南市| 玉田县| 镇雄县| 林周县| 延川县| 三亚市| 龙南县| 冕宁县| 古蔺县| 青岛市| 壶关县| 上栗县| 哈巴河县| 金湖县| 莱阳市| 博爱县|