1.微信公众平台完成小程序认证和备案。

配置服务类目:

2.购买域名并完成域名实名认证和备案,公安备案。

3.购买https证书。

下载证书:

4.创建目录 mkdir -p /home/app/exam/ssl。上传证书到该目录下。

5.创建nginx配置文件: vim /usr/local/nginx/conf/exam_app_nginx.conf 。内容如下:

user  root;

worker_processes  1;

#worker_cpu_affinity 0001 0010 0100 1000;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

error_log  /var/log/nginx/error.log  info;



pid        /run/nginx.pid;


events {

    use epoll;

    worker_connections  65535;

}


http {

    include       mime.types;

    default_type  application/octet-stream;



    log_format log_access '$remote_addr - $remote_user [$time_local] "$request" $http_host '

                          '$status $body_bytes_sent "$http_referer" '

                          '"$http_user_agent" "$http_x_forwarded_for" '

                          '"$upstream_addr" "$upstream_status" $upstream_cache_status "$upstream_http_content_type" "$upstream_response_time" > $request_time ' ;



    server_tokens off;

    sendfile on;

    tcp_nopush on;

    tcp_nodelay on;

    client_body_timeout  20;

    client_header_timeout 20;

    keepalive_timeout  3000;

    send_timeout       20;

    gzip on;

    gzip_min_length  1k;

    gzip_buffers     4 16k;

    gzip_http_version 1.0;

    gzip_comp_level 2;

    gzip_types       text/plain application/x-javascript text/css application/xml application/javascript  application/octet-stream;

    gzip_vary on;



    server {

         listen 443 ssl;

         server_name www.farsailing.com;

         ssl_certificate /home/app/exam/ssl/www.farsailing.com_bundle.crt;

         ssl_certificate_key /home/app/exam/ssl/www.farsailing.com.key;

         ssl_session_timeout 5m;

         ssl_protocols TLSv1.2 TLSv1.3;

         ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;

         ssl_prefer_server_ciphers on;



        location /exam-boot {

          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_pass http://119.29.209.39:8080;

          client_max_body_size 10m;

        }
        

        location =/b6dGmKoAux.txt {

            root /home/app/exam;

        }


        location /html {

            root /home/app/exam;

        }

    }

}

域名,证书地址,ip改为自己的。

6.开发管理中配置服务器域名和业务域名。

用于小程序调用下载接口,http请求接口和webview页面访问。

7.启动nginx:docker run --name exam_app_nginx  -p 80:80 -p 443:443-d -v /usr/local/nginx/conf/exam_app_nginx.conf :/etc/nginx/nginx.conf -v /home/app:/home/app --restart=always nginx

8.防火墙开放80,443端口。

9.运行到微信开发者。

修改配置:

10.上传到微信。

在微信公众平台扫描预览后,确认无误后提交审核。

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐