Niginx 配置

  1. 设置JS跨域
    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Methods' 'GET,POST,PUT,OPTIONS';
    add_header 'Access-Control-Allow-Headers' 'Content-type';

  2. 设置连接时间,用来解决连接超时问题504错误
    fastcgi_connect_timeout 600s; #单位秒
    fastcgi_send_timeout 600s;
    fastcgi_read_timeout 600s;
    以下是PHP配置

    location ~ \.php$ {
    #添加的js跨域代理
     add_header 'Access-Control-Allow-Origin' '*';
     add_header 'Access-Control-Allow-Credentials' 'true'; 
     add_header 'Access-Control-Allow-Methods' 'GET,POST,PUT,OPTIONS';
     add_header 'Access-Control-Allow-Headers' 'Content-type';
         root           C:\PHPWeb;
    fastcgi_connect_timeout 600s;
    fastcgi_send_timeout 600s;
    fastcgi_read_timeout 600s;
        fastcgi_buffer_size 128k;
       fastcgi_buffers 8 128k;#8 128
        fastcgi_busy_buffers_size 256k;
       fastcgi_temp_file_write_size 256k;
       fastcgi_intercept_errors on;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         include        fastcgi_params;
     }
    
     # deny access to .htaccess files, if Apache's document root
     # concurs with nginx's one
     #
     #location ~ /\.ht {
     #    deny  all;
     #}
      }
    

你可能感兴趣的:(Niginx 配置)