我试图代理从Nginx到kibana(logstash)的请求.我可以访问端口9292上的kibana仪表板 – 我可以确认服务正在侦听端口9292.我可以成功代理从Nginx到其他服务但是kibana的代理指令(端口9292)不起作用 – 我可以代理到9200对于弹性搜索.关于如何进一步解决这个问题的任何想法将不胜感激.
更新:
我已经尝试将上游的服务器设置更改为指向0.0.0.0以及服务器地址但两种选项都不起作用.请求将路由到默认服务器.
另一个更新:
我注意到从Nginx默认文件中删除代理参数允许我将请求转发到kibana listneing端口 – 但是,kibana抱怨缺少“dashboards / default.json”,我猜这是因为某些设置丢失或配置错误在Nginx.
默认(/ etc / Nginx / sites-available)
upstream logstash {
server 127.0.0.1:9292; ##kibana
keepalive 100;
}
server {
listen 84;
listen [::]:84 ipv6only=on;
root /var/www/;
index index.html index.htm;
server_name logstash;
##logging per server
access_log /var/log/Nginx/logstash/access.log;
error_log /var/log/Nginx/logstash/error.log;
location / {
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://logstash;
}
}
解决方法:
问题似乎是
proxy_pass http://your-logstash-host;
如果查看LogStash Web中的日志,您将看到“WARN – :Rack :: Protection :: JsonCsrf阻止了攻击”
有一些我不熟悉的内置安全性,由机架保护提供,以防止跨源资源共享攻击.问题是来自Nginx的proxy_pass看起来像是对ruby机架保护的CORS攻击.
编辑:
如前所述,模块Rack :: Protection :: CSRF是抛出此警告的模块.
我打开了代码,我们可以清楚地看到发生了什么:
def has_vector?(request, headers)
return false if request.xhr?
return false unless headers['Content-Type'].to_s.split(';', 2).first =~ /^\s*application\/json\s*$/
origin(request.env).nil? and referrer(request.env) != request.host
end
所以这里是传递请求所需的Nginx配置,以便Sinatra接受它们:
server {
listen 80;
server_name logstash.frontend.domain.org;
location / {
# Proxying all requests from logstash.frontend to logstash.backend
proxy_pass http://logstash.backend.domain.org:9292;
proxy_set_header X-Real-IP $remote_addr;
# Set Referer and Host to prevent CSRF panick by Sinatra
proxy_set_header Referer my-host-04;
proxy_set_header Host my-host-04.domain.org;
# Alternatively to setting the Referer and Host, you Could set X-Requested-With
#proxy_set_header X-Requested-With XMLHttpRequest;
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。