我尝试让 Kibana 在特定 Web 目录中的 nginx 后面运行。或者,换句话说,我尝试让 nginx 反向代理http://example.com/kibana
到http://localhost:5601/
,这是 Kibana sinatra 应用程序运行的地方。
我已经使用 init 脚本启动了 Kibana,如果我从服务器获取 URL,我会得到预期的响应。但是,导航到curl
会给我一个消息和一个应该执行某些操作的建议。据推测,这是一个路由问题。localhost
http://example.com/kibana/
Sinatra doesn’t know this ditty.
/kibana/
我的 nginx 配置非常简单:
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /kibana/ {
proxy_pass http://localhost:5601;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
答案1
我对上一个答案有一处修改。
proxy_pass http://127.0.0.1:5601;
替换为
proxy_pass http://127.0.0.1:5601/;
答案2
尝试这个:https://serverfault.com/a/379679/82682(最终替换'/foo/Kibana-0.2.0')
location /kibana {
# rewrite before passing to proxy
rewrite /kibana/(.*) /$1 break;
proxy_pass http://127.0.0.1:5601;
# include nginx' proxy-defaults
include proxy_params;
# serve static stuff directly from the static-directory
location /kibana/favicon.ico {
alias /foo/Kibana-0.2.0/static/favicon.ico;
}
location /kibana/images {
alias /foo/Kibana-0.2.0/static/images;
}
location /kibana/lib {
alias /foo/Kibana-0.2.0/static/lib;
}
}