55 lines
1.7 KiB
Nginx Configuration File
55 lines
1.7 KiB
Nginx Configuration File
|
|
worker_processes 1;
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
http {
|
|
include mime.types;
|
|
default_type application/octet-stream;
|
|
sendfile on;
|
|
keepalive_timeout 65;
|
|
map $proxy_protocol_addr $real_ip {
|
|
default $remote_addr;
|
|
}
|
|
server {
|
|
listen 4560;
|
|
server_name localhost;
|
|
client_header_buffer_size 64k;
|
|
large_client_header_buffers 8 128k;
|
|
client_max_body_size 50m;
|
|
|
|
location / {
|
|
root /app/html;
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
location /api {
|
|
proxy_pass http://localhost:5000/api;
|
|
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;
|
|
|
|
# 跨域配置
|
|
add_header Access-Control-Allow-Origin * 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;
|
|
add_header Access-Control-Allow-Credentials true always;
|
|
add_header Access-Control-Expose-Headers 'Content-Length, Content-Range' always;
|
|
|
|
# 处理OPTIONS预检请求
|
|
if ($request_method = 'OPTIONS') {
|
|
add_header Access-Control-Allow-Origin *;
|
|
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, PUT, DELETE';
|
|
add_header Access-Control-Allow-Headers 'Authorization, Content-Type, X-Requested-With, Accept, Origin';
|
|
add_header Access-Control-Max-Age 86400;
|
|
add_header Content-Length 0;
|
|
add_header Content-Type text/plain;
|
|
return 200;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|