我已将nginx配置为反向代理并缓存内容。我已成功将其配置为springboot应用程序的反向代理。但是,它不会缓存从springboot呈现的任何内容,而是在error.log
文件中看到日志。
以下是nginx.conf
文件:
http {
proxy_cache_path C:\nginx\data\nginx\cache levels=1:2 keys_zone=my-cache:8m max_size=1000m inactive=600m;
proxy_temp_path C:\nginx\data\nginx\tmp;
inactive=24h max_size=1g;
server {
listen 80;
server_name localhost;
location / {
# Backend server to forward requests to/from
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_cache my-cache;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 1m;
}
}
}
已尝试使用多个proxy_cache_path
选项,包括data/nginx/cache
,\data\nginx\cache
和C:/nginx/data/nginx/cache
。但是,事实上他们都没有工作,他们不允许停止/启动nginx。
以下是在nginx error.log
文件中观察到的错误:
2017/04/21 11:28:07 [emerg] 6352#528: CreateDirectory() "C:\nginx/\data\nginx\cache" failed (3: The system cannot find the path specified)
2017/04/21 11:28:53 [notice] 5748#6748: signal process started
2017/04/21 11:28:53 [emerg] 6352#528: CreateDirectory() "C:\nginx/data/nginx/cache" failed (3: The system cannot find the path specified)
2017/04/21 11:30:41 [notice] 5244#6032: signal process started
2017/04/21 11:30:41 [emerg] 6352#528: CreateDirectory() "C:
ginx\data
ginx\cache" failed (123: The filename, directory name, or volume label syntax is incorrect)
2017/04/21 11:31:41 [notice] 6716#5140: signal process started
2017/04/21 11:31:41 [emerg] 6352#528: CreateDirectory() "C:
ginx\data
ginx\cache" failed (123: The filename, directory name, or volume label syntax is incorrect)
2017/04/21 11:41:23 [crit] 6496#7100: *241 CreateFile() "C:\nginx/data/nginx/tmp/0000000003" failed (3: The system cannot find the path specified) while reading upstream, client: 172.23.66.69, server: localhost, request: "GET /js/splunkbar.js HTTP/1.1", upstream: "http://127.0.0.1:8080/js/splunkbar.js", host: "vi-dvw70765", referrer: "http://vi-dvw70765/checksplunk/13"
2017/04/21 11:41:25 [crit] 6496#7100: *245 CreateFile() "C:\nginx/data/nginx/tmp/0000000004" failed (3: The system cannot find the path specified) while reading upstream, client: 172.23.66.69, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8080/favicon.ico", host: "vi-dvw70765", referrer: "http://vi-dvw70765/checksplunk/13"
2017/04/21 11:48:04 [notice] 6732#6204: signal process started
2017/04/21 11:48:04 [emerg] 6352#528: CreateDirectory() "C:\nginx/data/nginx/cache" failed (3: The system cannot find the path specified)
2017/04/21 11:48:12 [notice] 6512#2300: signal process started
2017/04/21 11:48:18 [emerg] 1492#6744: CreateDirectory() "C:\nginx/data/nginx/cache" failed (3: The system cannot find the path specified)
2017/04/21 11:49:24 [emerg] 5168#2396: CreateDirectory() "C:\nginx/data/nginx/cache" failed (3: The system cannot find the path specified)
2017/04/21 11:49:40 [notice] 6368#1732: signal process started
2017/04/21 11:49:40 [error] 6368#1732: CreateFile() "C:\nginx/logs/nginx.pid" failed (2: The system cannot find the file specified)
2017/04/21 11:50:38 [notice] 3500#6476: signal process started
2017/04/21 11:50:38 [error] 3500#6476: CreateFile() "C:\nginx/logs/nginx.pid" failed (2: The system cannot find the file specified)
2017/04/21 11:50:57 [emerg] 2980#5288: "proxy_cache" zone "my-cache" is unknown in C:\nginx/conf/nginx.conf:141
2017/04/21 11:51:46 [notice] 5872#6156: signal process started
我已在网上搜索解决此问题,但无法找到解决此问题的方法。
非常感谢任何帮助/解决方案。
提前致谢。