title: nginx behind haproxy to static html ssl getting real IP address
body: <p>My problem is getting the "real" IP address from the web at nginx level serving a static vuejs site via ssl.</p>
  
  <p>I want to block certain IP addresses, how can I get the real IP address if I can't use proxy pass, since I only link to a static location?</p>
  
  <p>haproxy (tcp) (port: 443) ==> encrypted request ==> nginx (port: 8085) request pass to ==> '/' location getting real IP for range blocking.</p>
  
  <p>Please also see questions/comments in the nginx vhost file. Am I on the right track here or does this need to be done entirely differently?</p>
  
  <p>haproxy setup:</p>
  
  <pre><code>frontend ssl_front_433 xx.xx.xx.xx:443
      mode tcp
      option tcplog
      use_backend ssl_nginx_backend_8085
  
  backend ssl_nginx_backend_8085
      mode tcp
      balance roundrobin
      option  tcp-check
      server  srv-2 127.0.0.1:8085  check  fall 3 rise 2 inter 4s
  </code></pre>
  
  <p>nginx setup:</p>
  
  <pre><code>server {
     listen 8085 ssl;
     server_name mydomain;
  
     access_log /var/log/nginx/access.log;
     error_log  /var/log/nginx/error.log;
  
     ssl_certificate      ./fullchain.pem;
     ssl_certificate_key  ./privkey.pem;
     include include.d/ssl.conf;
  
     // I want to only allow certain ip addresses
     // haproxy of course always returns 127.0.0.1 thus this is not working 
     include include.d/ip_range.conf;  
  
     location / {
          //how to get the proxy headers to be applied here?
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_redirect off;
          // do I need a proxy pass and if so where should I pass to,
          // in order to use it with static html/js?
          // can I use an upstream to a static location?
          //proxy_pass http://;
          try_files $uri $uri/ /index.html;
     }
  }
  </code></pre>