title: Verify if nginx is working correctly with Proxy Protocol locally
body: <p><strong>Environment</strong></p>
  
  <p>I have set up Proxy Protocol support on an AWS classic load balancer as shown <a href="http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-proxy-protocol.html" rel="noreferrer">here</a> which redirects traffic to backend <a href="https://www.nginx.com/resources/admin-guide/proxy-protocol/" rel="noreferrer">nginx</a> (configured with <a href="https://www.modsecurity.org/" rel="noreferrer">ModSecurity</a>) instances.</p>
  
  <p>Everything works great and I can hit my websites from the open internet.</p>
  
  <p>Now, since my nginx configuration is done in AWS <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html" rel="noreferrer">User Data</a>, I want to do some checks before the instance starts serving traffic which is achievable through AWS Lifecycle hooks.</p>
  
  <p><strong>Problem</strong></p>
  
  <p>Before enabling <em>proxy protocol</em> I used to check whether my nginx instance is healthy, and ModSecurity is working by checking a <code>403</code> response from this command</p>
  
  <pre><code>$ curl -ks "https://localhost/foo?username=1'%20or%20'1'%20=%20'"
  </code></pre>
  
  <p>After enabling Proxy Protocol, I can't do this anymore as the command fails with below error which is expected as per this <a href="https://blog.mythic-beasts.com/2016/05/09/proxy-protocol-nginx-broken-header/" rel="noreferrer">link</a>.</p>
  
  <pre><code># curl -k https://localhost -v
  * About to connect() to localhost port 443 (#0)
  *   Trying ::1...
  * Connected to localhost (::1) port 443 (#0)
  * Initializing NSS with certpath: sql:/etc/pki/nssdb
  * NSS error -5938 (PR_END_OF_FILE_ERROR)
  * Encountered end of file
  * Closing connection 0
  curl: (35) Encountered end of file
  
  # cat /var/logs/nginx/error.log
  2017/10/26 07:53:08 [error] 45#45: *5348 broken header: "���4"�U�8ۭ�u��%d�z��mRN�[e��&lt;�,�
  �+̩�    �0��/̨��98k�̪32g�5=�/&lt;
  " while reading PROXY protocol, client: 172.17.0.1, server: 0.0.0.0:443
  </code></pre>
  
  <p>What other options do I have to programmatically check nginx apart from curl? Maybe something in some other language?</p>