zoukankan      html  css  js  c++  java
  • nginx的跨域设置

    官方文档 中说,只有当响应状态码为以下几种类型中之一时,add_header 才会生效。如果需要 add_header 在所有情况下都生效,可以在后面加上 always 参数即可解决。

    Adds the specified field to a response header provided that the response code equals 200, 201 (1.3.10), 204, 206, 301, 302, 303, 304, 307 (1.1.16, 1.0.13), or 308 (1.13.0). The value can contain variables.
    There could be several add_header directives. These directives are inherited from the previous level if and only if there are no add_header directives defined on the current level.
    If the always parameter is specified (1.7.5), the header field will be added regardless of the response code.

    参考配置

    
    server {
        listen 80;
        server_name servername;
        root /var/www/html;
        
        add_header Access-Control-Allow-Origin * always;
        add_header Access-Control-Allow-Methods * always;
    
    
        location ~ .php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include fastcgi.conf;
        }
    
    }
    
  • 相关阅读:
    主成分分析法(PCA)答疑
    搜索引擎的高级用法
    Makefile 编写实例
    GCC常用命令
    一个进程最多能开多少个线程?
    归并排序
    选择排序(数组、链表)
    求连续子数组的最大和
    生产者-消费者问题(1)
    基于cmake编译安装MySQL-5.5
  • 原文地址:https://www.cnblogs.com/lovesKey/p/11371242.html
Copyright © 2011-2022 走看看