无法通过 nginx 代理访问 apache web 服务器

无法通过 nginx 代理访问 apache web 服务器

我的 apache 服务器在以下 23.xxx.xxx.10:80 上运行。我尝试使用下面定义的 nginx 代理访问其中一个文件夹 (/var/www/cfbrokerlogs)。但是,当我尝试从浏览器访问时,出现 net::ERR_TOO_MANY_REDIRECTS 。我不确定我需要打开什么才能使其工作?

nginx.conf

location /cfbrokerlogs/ {
  proxy_pass                 http://23.xxx.xxx.10:80/cfbrokerlogs;
  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;
}

Apache 配置(apache2.conf)

    <VirtualHost *:80>


    WSGIDaemonProcess _graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120 user=_graphite group=_graphite
    WSGIProcessGroup _graphite
    WSGIImportScript /usr/share/graphite-web/graphite.wsgi process-group=_graphite application-group=%{GLOBAL}
    WSGIScriptAlias / /usr/share/graphite-web/graphite.wsgi

   Alias /content/ /usr/share/graphite-web/static/
      <Location "/cfbrokerlogs/">
      SetHandler None  
      Header set Access-Control-Allow-Origin "*"
      Header set Access-Control-Allow-Methods "GET, OPTIONS"
      Header set Access-Control-Allow-Headers "origin, authorization, accept"
       </Location>

      Header set Access-Control-Allow-Origin "*"
      Header set Access-Control-Allow-Methods "GET, OPTIONS"
      Header set Access-Control-Allow-Headers "origin, authorization, accept"


             Alias /cfbrokerlogs  /var/www/cfbrokerlogs
            <Directory /var/www/cfbrokerlogs>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
            </Directory>

    </VirtualHost>

答案1

nginx 的文档

如果 proxy_pass 指令指定了 URI,那么当请求传递给服务器时,规范化请求 URI 中与位置匹配的部分将被指令中指定的 URI 替换。

所以这里的意思是如果你点击http://<domain>/cfbrokerlogs/foo它,它将按照http://23.xxx.xxx.10:80/cfbrokerlogsfoo指令转发proxy_pass

在指令 URI 中添加尾部斜杠proxy_pass或将其从位置中删除。

相关内容