Nginx配置微信小程序校验

情况说明:工作中开发环境,前端需要接入微信小程序认证,进入Nginx配置文件进行配置,记录过程

Centos7的配置

# 版本详情
CentOS Linux release 7.7.1908 (Core)

nginx version: nginx/1.16.1

# 进入nginx子配置文件
cd /etc/nginx/conf.d

vim wechat_auth.conf
server {
    listen       80;
    server_name  pakho.com;

    location /37og2Z5TwR.txt {
                default_type    text/html;
                return 200 "6831c2a15d3d103c6a1ff356b22b5";
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

Ubuntu 的配置

# 版本详情
Linux version 4.14.105-19-0012 (root@pakho.site) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC)) 

nginx version: nginx/1.14.0 (Ubuntu)

vim /etc/nginx/nginx.conf

        # Virtual Host Configs
        ##
server {
	listen       80;
	server_name  pakho.com;

	location /37og2Z5TwR.txt {
				default_type    text/html;
                        return 200 "6831c2a15d3d103c6a1ff356b22b5";
	}
}

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

配置完成后进入腾讯云负载均衡配置,域名+/37og2Z5TwR.txt,加入后端realServer

GitHub 加速计划 / li / linux-dash
6
1
下载
A beautiful web dashboard for Linux
最近提交(Master分支:3 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐