小程序部署步驟

此處以阿里雲服務器爲例:

申請阿里雲服務器;
在阿里雲服務器上安裝nginx,做反向代理(映射);
nginx的配置如下:

 

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    upstream tomcat_server{
    #server ht.shenghui56.com/ntocc_chauffeur_web;
    server 127.0.0.1;
    }
    server {
        listen       8078;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass   http://tomcat_server;
        
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
       # location ~ \.php$ {
        #    proxy_pass   tomcat_server;
       # }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    server {
      listen 443;
    #server_name 101.132.152.185;
        server_name www.htoline.com;  # localhost修改爲您證書綁定的域名。
    ssl on;   #設置爲on啓用SSL功能。
    ssl_certificate cert/2761253_htoline.com.pem;   #將domain name.pem替換成您證書的文件名。
    ssl_certificate_key cert/2761253_htoline.com.key;   #將domain name.key替換成您證書的密鑰文件名。
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;  #使用此加密套件。
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;   #使用該協議進行配置。
    ssl_prefer_server_ciphers on;   
    location / {
    #proxy_pass http://127.0.0.1:80;
    #proxy_pass 這個設置真實的調用接口,設置必需爲ip。
    proxy_pass http://59.56.179.12:80;
    root   html;
 
    index index.html index.htm;
       proxy_set_header Host $host;
        proxy_set_header  X-Real-IP        $remote_addr;
        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;

    }
    }

}

 

在conf目錄下,新建cert文件夾,存放證書的兩個文件;

在阿里雲管理服務器上開發443入接口與nginx其餘出入接口;ip配置爲:0.0.0.0/0


2.在阿里雲上申請證書。

證書的審覈認證選擇自動,將驗證的名稱 設置成創建的.txt文件的名稱,內容爲其驗證的內容,放置1.中的阿里雲服務器中的可訪問路徑下,可用.txt替換爲tomcat的index頁面。
點擊審覈認證通過的證書的nginx配置下載,按照提示進一步安裝,即可。

在nignx的https server配置中,將證書內容安裝相應配置進行配置,即可。

3.在微信公衆平臺,登錄開發者管理對域名進行配置(一個月僅可配置5次)。
在小程序開發工具的設置中,將https校驗開啓,更換好域名後,重新提交代碼,審覈-發佈,即可。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章