Files
2025-10-07 15:58:15 +08:00

47 lines
1.9 KiB
Plaintext

upstream prod_py_search {
# ip_hash;
# hash $http_x_forwarded_for consistent;
server 10.0.0.13:7001 weight=10 max_fails=3 fail_timeout=30s;
server 10.0.0.12:7001 weight=10 max_fails=3 fail_timeout=30s;
server 10.0.0.7:7001 weight=10 max_fails=3 fail_timeout=30s;
server 10.0.0.11:7001 weight=10 max_fails=3 fail_timeout=30s;
server 10.0.0.2:7001 weight=10 max_fails=3 fail_timeout=30s;
}
log_format prod_py_search_log '客户端IP: $remote_addr | 用户: $remote_user | 时间: $time_local | '
'请求方法和路径: "$request" | 状态码: $status | 响应大小: $body_bytes_sent | '
'XFF: "$http_x_forwarded_for" | 客户端UA: "$http_user_agent" | '
'上游服务器: $upstream_addr | 上游响应耗时: $upstream_response_time | '
'请求总耗时: $request_time | Host: $host';
server{
listen 50201;
server_name _;
access_log /data/tengine/logs/python_prod_agent_ip_access.log prod_py_search_log;
error_log /data/tengine/logs/python_prod_agent_ip_error.log;
location / {
proxy_pass http://prod_py_search;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_cache off;
proxy_http_version 1.1;
proxy_set_header Connection "";
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always;
if ($request_method = OPTIONS ) {
return 204;
}
}
}