server {
  listen __port__;
  server_name test1.example.com test2.example.com;
  root __pwd__/e2e-tests/conf/site;

  # Internal authentication request
  location = /lmauth {
    internal;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:__pwd__/e2e-tests/conf/llng-fastcgi.sock;
    #fastcgi_pass 127.0.0.1:9090;
    #fastcgi_param RULES_URL "http://test2.example.com:__port__/test.json";
    #fastcgi_param VHOSTTYPE "DevOps";

    # Drop post datas
    fastcgi_pass_request_body  off;
    fastcgi_param CONTENT_LENGTH "";

    # Keep original hostname
    fastcgi_param HOST $http_host;

    # Keep original request (LLNG server will received /llauth)
    fastcgi_param X_ORIGINAL_URI  $request_uri;

    # OU TO USE uWSGI
    #include /etc/nginx/uwsgi_params;
    #uwsgi_pass 127.0.0.1:5000;
    #uwsgi_pass_request_body  off;
    #uwsgi_param CONTENT_LENGTH "";
    #uwsgi_param HOST $http_host;
    #uwsgi_param X_ORIGINAL_URI  $request_uri;
  }

  # Client requests
  location / {
    index index.pl;
    try_files $uri $uri/ =404;
    auth_request /lmauth;
    auth_request_set $lmremote_user $upstream_http_lm_remote_user;
    auth_request_set $lmlocation $upstream_http_location;
    error_page 401 $lmlocation;
    include conf/nginx-lua-headers.conf;
  }

  location /test.json {
    auth_request off;
    allow 127.0.0.0/8;
    deny all;
  }

  location /rules.json {
    auth_request off;
    allow 127.0.0.0/8;
    deny all;
  }

  # Handle test CGI
  location ~ \.pl$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:__pwd__/e2e-tests/conf/llng-fastcgi.sock;
    fastcgi_param LLTYPE cgi;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_split_path_info ^(.*\.pl)(/.+)$;
    # Set REMOTE_USER (for FastCGI apps only)
    fastcgi_param REMOTE_USER $lmremote_user;
  }

  location = /status {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:__pwd__/e2e-tests/conf/llng-fastcgi.sock;
    fastcgi_param LLTYPE status;
  }

}
