2014-10-10 3 views
0

자바 스크립트를 사용하여 아파치가 실행중인 백엔드 서버를 호출합니다. 나는 nginx 프록시를 설치하고 아파치 2가 실행 중일 때 서버를 통해 모든 흑연 및 탄성 검색 요청을 라우트합니다.Nginx 프록시가 예상대로 실행되지 않습니다.

Nginx는 프록시 호출을 서버에 보내지 만 URL 끝 부분에 위치를 추가합니다.

예 : http://10.xxx.xxx.23/graphite을 nginx로 전달하면 http://23.xxx.xxx.1:80/graphite이 호출됩니다. 나는/흑연을 결국 원하지 않는다. 간단히 전화를 걸고 싶다. http://23.xxx.xxx.1:80?

나는

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; 
    } 


    } 
} 

답변

1

대신

proxy_pass     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 파일을 붙여 넣은 위치

proxy_pass     http://23.xxx.xxx.1:80/; 
관련 문제