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

大功告成!!!!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章