English 中文(简体)
空研中心代理规程使Nginx处于侵略控制状态的人屈服于坏要求。
原标题:NLB proxy protocol enabled causes Nginx ingress controller to throw bad request

I ve a Kubernetes group which isshop in AWS (EKS).

我试图保护客户IP。 为此,我尝试在网络负荷平衡器中采用有利的代理协议第2号,该平衡器在分组前坐,并配置了处于侵略状态的控制器来处理。

然而,每份请求中,有一米申请有坏的错误,没有任何额外信息。

这是我的Nginx ingress controller configMap

apiVersion: v1
data:
  allow-snippet-annotations: "true"
  compute-full-forwarded-for: "true"
  enable-real-ip: "true"
  server-snippet: "listen 8000;
if ( $server_port = 80 ) {
   return 308 https://$host$request_uri;
}
      
"
  ssl-redirect: "false"
  use-forwarded-headers: "true"
  use-proxy-protocol: "true"

在Nginx config中,哪些是这样

    ## start server 
    server {
        server_name [REDACTED] ;
        
        listen 80 proxy_protocol ;
        listen 443 proxy_protocol ssl http2 ;
        
        set $proxy_upstream_name "-";
        
        ssl_certificate_by_lua_block {
            certificate.call()
        }
        
        location / {
            
            set $namespace      "[REDACTED]";
            set $ingress_name   "[REDACTED]";
            set $service_name   "[REDACTED]";
            set $service_port   "[REDACTED]";
            set $location_path  "/";
            set $global_rate_limit_exceeding n;
            
            rewrite_by_lua_block {
                lua_ingress.rewrite({
                    force_ssl_redirect = false,
                    ssl_redirect = false,
                    force_no_ssl_redirect = false,
                    preserve_trailing_slash = false,
                    use_port_in_redirects = false,
                    global_throttle = { namespace = "", limit = 0, window_size = 0, key = { }, ignored_cidrs = { } },
                })
                balancer.rewrite()
                plugins.run()
            }
                        
            header_filter_by_lua_block {
                lua_ingress.header()
                plugins.run()
            }
            
            body_filter_by_lua_block {
                plugins.run()
            }
            
            log_by_lua_block {
                balancer.log()
                
                monitor.call()
                
                plugins.run()
            }
            
            port_in_redirect off;
            
            set $balancer_ewma_score -1;
            set $proxy_upstream_name "[REDACTED]";
            set $proxy_host          $proxy_upstream_name;
            set $pass_access_scheme  $scheme;
            
            set $pass_server_port    $proxy_protocol_server_port;
            
            set $best_http_host      $http_host;
            set $pass_port           $pass_server_port;
            
            set $proxy_alternative_upstream_name "";
            
            client_max_body_size                    20m;
            
            proxy_set_header Host                   $best_http_host;
                        
            # Allow websocket connections
            proxy_set_header                        Upgrade           $http_upgrade;
            
            proxy_set_header                        Connection        $connection_upgrade;
            
            proxy_set_header X-Request-ID           $req_id;
            proxy_set_header X-Real-IP              $remote_addr;
            
            proxy_set_header X-Forwarded-For        $full_x_forwarded_for;
            
            proxy_set_header X-Forwarded-Host       $best_http_host;
            proxy_set_header X-Forwarded-Port       $pass_port;
            proxy_set_header X-Forwarded-Proto      $pass_access_scheme;
            proxy_set_header X-Forwarded-Scheme     $pass_access_scheme;
            
            proxy_set_header X-Scheme               $pass_access_scheme;
            
            # Pass the original X-Forwarded-For
            proxy_set_header X-Original-Forwarded-For $http_x_forwarded_for;
            
            proxy_set_header Proxy                  "";
                        
            proxy_connect_timeout                   5s;
            proxy_send_timeout                      3600s;
            proxy_read_timeout                      3600s;
            
            proxy_buffering                         off;
            proxy_buffer_size                       4k;
            proxy_buffers                           4 4k;
            
            proxy_max_temp_file_size                1024m;
            
            proxy_request_buffering                 on;
            proxy_http_version                      1.1;
            
            proxy_cookie_domain                     off;
            proxy_cookie_path                       off;
            
            proxy_next_upstream                     error timeout;
            proxy_next_upstream_timeout             0;
            proxy_next_upstream_tries               3;
            
            proxy_pass http://upstream_balancer;
            
            proxy_redirect                          off;
            
        }
        
        # Custom code snippet configured in the configuration configmap
        listen 8000;
        if ( $server_port = 80 ) {
            return 308 https://$host$request_uri;
        }   
        
    }
    ## end server

在我的吉大港山区目标人群中,通过AWS Console,使Proxy 规程 v2成为可能,但当有人打过任何终点时,结果就是结果。

<html>

<head>
    <title>400 Bad Request</title>
</head>

<body>
    <center>
        <h1>400 Bad Request</h1>
    </center>
    <hr>
    <center>nginx</center>
</body>

</html>

任何帮助都是巨大的。

提前感谢。

问题回答

To configure NGINX to accept PROXY protocol headers, add the proxy_protocol parameter to the listen directive in a server block in the http {} or stream {} block. https://docs.nginx.com/nginx/admin-guide/load-balancer/using-proxy-protocol/

  • Adding below worked for me
http {

    server {
        listen 80   proxy_protocol;

    }
}




相关问题
Mount windows shared drive to MWAA in bootscript

In MWAA startup script sudo yum install samba-client cifs-utils -y sudo mount.cifs //dev/test/drop /mnt/dev/test-o username=testuser,password= pwd ,domain=XX Executing above commonds giving error - ...

How to get Amazon Seller Central orders programmatically?

We have been manually been keying Amazon orders into our system and would like to automate it. However, I can t seem to figure out how to go about it. Their documentation is barely there. There is: ...

Using a CDN like Amazon S3 to control access to media

I want to use Amazon S3/CloudFront to store flash files. These files must be private as they will be accessed by members. This will be done by storing each file with a link to Amazon using a mysql ...

unable to connect to database on AWS

actually I have my website build with Joomla hosted on hostmonster but all Joomla website need a database support to run this database is on AWS configuration files need to be updated for that I ...

Using EC2 Load Balancing with Existing Wordpress Blog

I currently have a virtual dedicated server through Media Temple that I use to run several high traffic Wordpress blogs. Both tend to receive sudden StumbleUpon traffic surges that (I m assuming) ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

热门标签