小程序的验证文件在nginx的配置

说明:最近公司的java程序中做了好多小程序,需要在域名中配置对应的小程序验证文件,具体配置是每个域名中都需要添加。具体如下:

  1. 先把小程序的验证文件(1个TXT)上传到nginx 服务器的某个目录,在此上传到 /usr/local/nginx/html/xcx ;


    image.png
  2. 编辑域名文件的配置文件
    vim /usr/local/nginx/conf/include/wxapp.xyx.conf 添加如下:

server
  {
   listen   80;
   listen   443 ssl;

    server_name  wxapp.xyx.com;
    #deny all;

    set $mylight "";
     if ($http_accept_encoding ~* gzip) {
      set $mylight "gzip";
     }

     ssl_certificate   /usr/local/nginx/cert/xyx2.com.pem;
     ssl_certificate_key  /usr/local/nginx/cert/xyx2.com.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 /6Hg3QD657b.txt {
        root /usr/local/nginx/html/xcx;
    }
    location / {
         root   html;
         #index  index.html index.htm;
         gzip on;
         proxy_next_upstream http_502 http_504 error timeout invalid_header;
         #proxy_cache cache_one;
         #proxy_cache_valid 200 304 12h;
         #proxy_cache_key $host$uri$is_args$args;
         proxy_set_header Host $host;
         proxy_set_header X-Forwarded-For $remote_addr;
         proxy_pass http://wxapp_cluster;
         #expires 1d;

}
 access_log  /www/nginx/logs/wxapp.xyx.com.log  access;
}

配置完用reload nginx后进行验证配置。https://wxapp.xyx.com/6Hg3QD657b.txt

你可能感兴趣的:(小程序的验证文件在nginx的配置)