windows子系统之openresty

1:windows子系统安装

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

windows子系统之openresty_第1张图片

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

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

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

windows子系统之openresty_第2张图片

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

大功告成!!!!

你可能感兴趣的:(学习笔记,openresty,windows,子系统,openresty)