我调用后端服务器,apache正在使用Javascript运行。我已经设置了一个nginx代理,并通过它将所有的graphite和elasticsearch请求路由到apache2正在运行的服务器。
Nginx会对服务器进行代理调用但是,它会将位置添加到URL的末尾。
例如:http://10.xxx.xxx.23/graphite传递给nginx时会调用http://23.xxx.xxx.1:80/graphite。我不希望/ graphite最终我想要ngix简单地调用http://23.xxx.xxx.1:80?
我已将我的nginx.conf文件粘贴到
下面config.js
datasources: {
graphite: {
type: 'graphite',
url: "http://" + window.location.host + "/graphite",
},
elasticsearch: {
type: 'elasticsearch',
url: "http://" + window.location.host + "/elasticsearch",
index: 'grafana-dash',
grafanaDB: true,
}
}
nginx.conf
worker_processes 1;
daemon off;
error_log <%= ENV["APP_ROOT"] %>/nginx/logs/error.log;
events { worker_connections 1024; }
http {
log_format cloudfoundry '$http_x_forwarded_for - $http_referer - [$time_local] "$request" $status $body_bytes_sent';
access_log <%= ENV["APP_ROOT"] %>/nginx/logs/access.log cloudfoundry;
default_type application/octet-stream;
include mime.types;
sendfile on;
gzip on;
tcp_nopush on;
keepalive_timeout 30;
server {
listen <%= ENV["PORT"] %>;
server_name localhost;
location / {
root <%= ENV["APP_ROOT"] %>/public;
index index.html index.htm Default.htm;
<% if File.exists?(File.join(ENV["APP_ROOT"], "nginx/conf/.enable_directory_index")) %>
autoindex on;
<% end %>
<% if File.exists?(auth_file = File.join(ENV["APP_ROOT"], "nginx/conf/.htpasswd")) %>
auth_basic "Restricted"; #For Basic Auth
auth_basic_user_file <%= auth_file %>; #For Basic Auth
<% end %>
}
location /graphite {
proxy_pass http://23.xxx.xxx.1:80;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header Host $host;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
location /elasticsearch {
proxy_pass http://23.xxx.xxx.1:9080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header Host $host;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
}
答案 0 :(得分:1)
而不是
proxy_pass http://23.xxx.xxx.1:80;
尝试此操作以避免位置
proxy_pass http://23.xxx.xxx.1:80/;