mirror of
https://github.com/luxfi/nginx.git
synced 2026-11-16 21:26:33 +00:00
- Add generic /ext/ location to proxy all extension APIs to luxd - Configure proper CORS headers for all API endpoints - Support WebSocket connections for any /ext path - Ensure health, info, metrics, and blockchain APIs are accessible - Root path (/) continues to proxy to C-Chain RPC for compatibility
35 lines
1.5 KiB
SYSTEMD
35 lines
1.5 KiB
SYSTEMD
# ZOO Network API
|
|
server {
|
|
listen 8080;
|
|
listen [::]:8080;
|
|
server_name api.zoo.network;
|
|
|
|
location / {
|
|
# Add CORS headers
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
|
|
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
|
|
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
|
|
|
|
# Handle preflight requests
|
|
if ($request_method = 'OPTIONS') {
|
|
add_header 'Access-Control-Allow-Origin' '*';
|
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
|
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
|
|
add_header 'Access-Control-Max-Age' 1728000;
|
|
add_header 'Content-Type' 'text/plain; charset=utf-8';
|
|
add_header 'Content-Length' 0;
|
|
return 204;
|
|
}
|
|
|
|
proxy_pass http://127.0.0.1:9630/ext/bc/bXe2MhhAnXg6WGj6G8oDk55AKT1dMMsN72S8te7JdvzfZX1zM/rpc;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection 'upgrade';
|
|
proxy_set_header Host $host;
|
|
proxy_cache_bypass $http_upgrade;
|
|
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;
|
|
}
|
|
} |