server { listen 127.0.0.1:1601; set $my_host 127.0.0.1:1601; set_real_ip_from 0.0.0.0/0; real_ip_header X-Real-IP; root /var/www/echoIP; error_page 403 404 = /error.html; location ^~ /assets {} location = /index.html {} location = /error.html {} location = /error { index error.html; } location = /ua { if ($http_user_agent ~* (curl|wget)) { return 200 $http_user_agent\n; } default_type application/json; return 200 $http_user_agent; } location = / { set $query_param ?justip=true&cli=true; if ($http_user_agent ~* (curl|wget)) { proxy_pass http://$my_host/query$query_param; } index index.html; } location / { set $query_param $query_string; if ($http_user_agent ~* (curl|wget)) { set $query_param $query_param&cli=true; } include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_param QUERY_STRING $query_param; fastcgi_param SCRIPT_FILENAME /var/www/echoIP/backend/queryInfo.php; } }