返回頂部
關閉軟件導航
位置:首頁 > 技術分享 > SEO優化>搭建微信小程序基本的https與wss環境

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

一、程序演示

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

1、預備工作

域名一個

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

Centos服務器一臺

nginx1.10.2

2、安裝nginx

安裝教程

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

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

3、配置nginx實現ssl反向代理

將下載好的證書根據自己的服務器選擇證書這里選擇nginx證書

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

這里我們直接上傳到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環境

#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微信小程序上傳大圖片時可能需要設置

}

新建wss.conf

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

upstreamwebsocket{

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

}

upstreamweb{

server;#遠程接口

}

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

server{

listen443;#默認s和wss協議端口

sslon;

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

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

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協議轉發小程序里面要訪問的鏈接

location/wss{

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

proxy__version1.1;

proxy_set_headerUpgrade$_upgrade;

proxy_set_headerConnection"Upgrade";

}

#s協議轉發小程序里面要訪問的鏈接

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*;#跨域訪問設置

}

}

```

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

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

主站蜘蛛池模板: 99精品国产在热久久无码| 亚洲爆乳无码专区| 99热门精品一区二区三区无码| 中文无码熟妇人妻AV在线| 中文字幕AV中文字无码亚| 亚洲色在线无码国产精品不卡| 国产精品99久久久精品无码| 最新无码人妻在线不卡| 野花在线无码视频在线播放| 亚洲综合无码一区二区痴汉| 亚洲成AV人片在线观看无码| 亚洲精品国产日韩无码AV永久免费网| 亚洲国产成AV人天堂无码 | 五月天无码在线观看| 无码精品一区二区三区免费视频 | 无翼乌工口肉肉无遮挡无码18| 无码乱人伦一区二区亚洲一| 日韩人妻无码一区二区三区久久99 | 亚洲中文久久精品无码1| a级毛片无码免费真人久久| 日韩AV无码精品一二三区| 亚洲久热无码av中文字幕| 日韩网红少妇无码视频香港| 亚洲国产a∨无码中文777| 寂寞少妇做spa按摩无码| 波多野结衣AV无码| 国产成人无码A区在线观看视频| 无码成人AAAAA毛片| 18精品久久久无码午夜福利| 无码av免费一区二区三区| 日韩精品无码免费一区二区三区| 中文字幕久久精品无码| 国产乱子伦精品无码码专区| 亚洲爆乳无码专区| 亚洲AV成人噜噜无码网站| 无码熟妇人妻av| 久久精品无码免费不卡| 国产成人无码av| 亚洲va成无码人在线观看| 蜜桃AV无码免费看永久| 免费无码A片一区二三区|