forked from hesabix/arc
45 lines
1.7 KiB
Text
Executable file
45 lines
1.7 KiB
Text
Executable file
# Nginx configuration for api.hesabix.ir
|
|
# This configuration proxies requests to localhost:8000 with CORS enabled
|
|
|
|
server {
|
|
listen 80;
|
|
server_name api.hesabix.ir;
|
|
|
|
# CORS headers - Allow all origins
|
|
add_header Access-Control-Allow-Origin "*" always;
|
|
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS, PATCH" always;
|
|
add_header Access-Control-Allow-Headers "Authorization, Content-Type, Accept, X-Requested-With" always;
|
|
add_header Access-Control-Allow-Credentials "true" always;
|
|
|
|
# Handle preflight OPTIONS requests
|
|
location / {
|
|
if ($request_method = 'OPTIONS') {
|
|
add_header Access-Control-Allow-Origin "*" always;
|
|
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS, PATCH" always;
|
|
add_header Access-Control-Allow-Headers "Authorization, Content-Type, Accept, X-Requested-With" always;
|
|
add_header Access-Control-Max-Age "3600" always;
|
|
add_header Content-Type "text/plain charset=UTF-8" always;
|
|
add_header Content-Length "0" always;
|
|
return 204;
|
|
}
|
|
|
|
proxy_pass http://127.0.0.1:8000;
|
|
proxy_http_version 1.1;
|
|
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;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Port $server_port;
|
|
|
|
proxy_connect_timeout 60s;
|
|
proxy_send_timeout 300s;
|
|
proxy_read_timeout 300s;
|
|
|
|
client_max_body_size 1g;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
}
|
|
}
|
|
|