官方文档 中说,只有当响应状态码为以下几种类型中之一时,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;
} }

最新文章

  1. Centos7下dnscrypt-proxy安装
  2. iOS--通讯录(UITableViewController)
  3. Linux命令(21)查看文件的行数
  4. How to Use Telnet to Test SMTP Communication
  5. hdu 5340 Three Palindromes
  6. JAVA 对象内存分析
  7. 从零開始学android<RelativeLayout相对布局.十六.>
  8. 使用Heartbeat实现双机热备
  9. MyBatis学习-映射文件标签篇(select、resultMap)
  10. Dapper中条件为In的写法
  11. Swiper4.x使用方法
  12. JVM基础系列第9讲:JVM垃圾回收器
  13. 网络层HTPPS和HTTP的概念与区别
  14. 垃圾wps弹出,现在连关闭按钮都不给了
  15. Mysql数据库的加密与解密
  16. python 全栈开发,Day133(玩具与玩具之间的对话,基于jieba gensim pypinyin实现的自然语言处理,打包apk)
  17. python实现合并两个文件并打印输出
  18. MongoDB的管理
  19. CRLF line terminators导致shell脚本报错:command not found --转载
  20. 安装配置SVN

热门文章

  1. SQL Server2008导入导出数据库
  2. FTP搭建注意事项
  3. 转 winfrom组件圆角
  4. linux--安全加固脚本
  5. iOS - Scenekit3D引擎初探之 - 导入模型+上传服务器+下载并简单设置
  6. vue实现组件切换的两种方式
  7. rabbitMQ centos7 的安装
  8. vue 打印html
  9. 华为SDN:解决传统网络3大问题
  10. springboot中的小技巧