worker_processes  4;

events {
	worker_connections  4096;
}

http {
	include mime.types;
	default_type application/octet-stream;
	sendfile on;
	keepalive_timeout 65;
	resolver 8.8.8.8 1.1.1.1 valid=600s;
	resolver_timeout 10s;

	limit_req_zone $binary_remote_addr zone=perip:10m rate=10r/s;
	limit_req zone=perip burst=20 nodelay;
	limit_req_status 429;
	limit_req_log_level warn;
	proxy_set_header Host $host;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Forwarded-Proto $scheme;

log_format debug '$remote_addr - $remote_user [$time_local] '
                    '"$request" $status $body_bytes_sent '
                    'host="$host" '
                    'referer="$http_referer" '
                    'ua="$http_user_agent" '
                    'xff="$http_x_forwarded_for" '
                    'xreal="$http_x_real_ip" '
                    'openai_hash="$http_x_openai_host_hash" '
                    'rt=$request_time '
                    'urt=$upstream_response_time '
                    'upstream="$upstream_addr"';
  log_format full '$remote_addr - $remote_user [$time_local] '
              '"$request" $status $body_bytes_sent '
              '"$http_referer" "$http_user_agent" '
              'X-Forwarded-For: $http_x_forwarded_for';

  # Enable access log globally (all requests)
  access_log /Users/administrator/hghosting/logs/nginx_access.log full;
  error_log /Users/administrator/hghosting/logs/nginx_error.log;

	server {
		listen 80;
		include nginx.default.conf;
		include config/nginx.custom.*.conf;
		include config/nginx.conf;
	}
	include config/nginx.ssl.*.conf;
}
