我试图修复500个内部服务器错误的安全漏洞,泄露文件的位置。
我的问题类似于(https://cdn-images-1.medium.com/max/1600/1*2DAwIEJhgLQd82t5WTgydA.png)
我受够了
proxy_intercept_errors启动;
和
error_page 500
改变方向,但没有帮助。
在这方面有什么帮助吗?
发布于 2018-08-19 06:49:43
这是实现proxy_intercept_errors on;的基本示例。
upstream foo {
server unix:/tmp/foo.sock;
keepalive 60;
}
server {
listen 8080 default_server;
server_name _;
location = /errors/5xx.html {
internal;
root /tmp;
}
location / {
proxy_pass http://foo;
proxy_http_version 1.1;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_intercept_errors on;
error_page 500 501 502 503 504 505 404 =200 /errors/5xx.html;
}
}注意:
error_page 500 501 502 503 504 505 404 =200 /errors/5xx.html;这将拦截一些5xx错误和404除外,并返回200。
另外,检查/errors/5xx.html位置,正在使用root /tmp;,因此仍然需要创建文件errors/5xx.html
$ mkdir /tmp/errors
$ echo "intercepting errors" > /tmp/errors/5xx.hml您不一定需要一个文件来回复您的请求,您也可以使用如下所示:
location = /errors/5xx.html {
internal;
default_type text/plain;
return 200 'Hello world!';
}在您的示例中,未找到的404文件可能处理不同,例如:
upstream failover{
server server2:8080;
}
server {
listen 80;
server_name example.com;
root /tmp/test;
location ~* \.(mp4)$ {
try_files $uri @failover;
}
location @failover {
proxy_pass http://failover;
}
}在这种情况下,如果没有找到以.mp4结尾的文件,它将尝试另一台服务器,那么如果需要,您仍然可以在那里调解错误。
https://stackoverflow.com/questions/51914539
复制相似问题