Nginx跨域配置

server{
    listen 8400;
    #server_name api.invest.modeling.ai;
    access_log  logs/api_modeling_access.log main;
    error_log   logs/api_modeling_error.log;
 
    add_header Access-Control-Allow-Origin $http_origin;
    add_header Access-Control-Allow-Credentials true;
    add_header Access-Control-Allow-Headers Origin,X-Requested-Width,Content-Type,Accept;
    add_header Access-Control-Allow-Methods *;
    add_header Access-Control-Max-Age 1728000;
    if ($request_method = 'OPTIONS') {
        return 204;
    }
 
    location / {
        proxy_pass http://127.0.0.1:8404;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Connection "";
        proxy_http_version 1.1;
    }
 
    location ~ /\.(ht|svn|git) {
        deny all;
    }
}

你可能感兴趣的:(Nginx服务,Nginx部署)