AWS Web控制台的Nginx反向代理配置

时间:2017-01-13 06:05:07

标签: amazon-web-services nginx proxy reverse-proxy http-proxy

有没有办法通过我的子域名通过nginx反向代理访问AWS Web控制台?

这是nginx配置一直在使用:

server {
  listen localhost:443 ssl;
  server_name aws1.subdomain.com;
  include snippets/proxy_ssl.conf;
  location / {
      proxy_pass              https://console.aws.amazon.com/;
      proxy_set_header        Host $host;

      proxy_http_version      1.1;
      proxy_set_header        Upgrade $http_upgrade;
      proxy_set_header        Connection "Upgrade";
      proxy_read_timeout      86400;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-Server $host;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

      proxy_redirect          off;
      proxy_hide_header X-Frame-Options;
  }
}

以上配置抛出:

  

NetworkError:400 Bad Request

当我尝试在浏览器中访问https://aws1.subdomain.com时,会显示亚马逊默认的400个错误请求页面。

1 个答案:

答案 0 :(得分:0)

我在nginx.conf中使用以下行进行此操作。您还可以根据需要为http auth添加行。

location = / { rewrite ^ /_plugin/kibana/ redirect; }
location / { 
  proxy_pass https://<es-domain-url>.es.amazonaws.com; 
  proxy_http_version 1.1; 
  proxy_set_header Authorization ""; 
  proxy_hide_header Authorization; 
  proxy_set_header X-Forwarded-Proto $scheme; 
}