windows子系统之openresty

1:windows子系统安装

  • 控制面板--->程序和功能--->启用或关闭Windows功能--->适用于Linux的Windows子系统

  • Microsoft Store--->搜索"ubuntu",安装即可。

2:openresty安装(官方安装文档)

  • 输入如下命令,进行编辑:(将server配置挂载至windows目录下,方便扩展)
sudo vim /usr/local/openresty/nginx/conf/nginx.conf

include /mnt/c/demo/openresty/test1/*.conf;

include /mnt/c/demo/openresty/test2/*.conf;
  • 在对应模块下(test1或者test2或者其他)编辑server conf
upstream proxy {
	server 10.*.*.*:8080;
}
	
server {
	listen 20030;
	client_max_body_size 4m;
	more_clear_headers "Server";
	more_clear_headers "X-AspNet-Version";
	more_clear_headers "X-Powered-By";
    
	location ~(favicon.ico) {
	    log_not_found off;
		  expires 99d;
		  break;
	}
    
	location / {
		root /mnt/c/demo//wwwroot;
		index Index.html;    
	}

	location ~/accesstokens/accesstokenget {
		internal;
		proxy_pass http://proxy;
	}

	location ~/(sz|wx|sh)/([-_a-zA-Z0-9/]+)/([-_a-zA-Z0-9/]+) {
		default_type application/json;
		set $monitor_module $2;
		set $monitor_action $3;
		access_by_lua_file  /mnt/c/demo/lua/checkAccess.lua;
		proxy_pass http://proxy;
	}
}
  • nginx reload
sudo /usr/local/openresty/nginx/sbin/nginx -s reload

大功告成!!!!

猜你喜欢

转载自blog.csdn.net/jinyidong/article/details/83826877