宝塔Nginx配置反向代理后如何配置跨域?

直接将 27行更换成如下配置即可 上图有示例

php 复制代码
  if ( $static_fileAUWz2fmi = 0 )
    {
        add_header Cache-Control no-cache;
        add_header 'Access-Control-Allow-Origin' "$http_origin";
    add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
    add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type    ';
    add_header 'Access-Control-Allow-Credentials' 'true';
    }

配置完成后,不重启Nginx也是可以用的,宝塔会自动重载配置。

相关推荐
sxgzzn44 分钟前
光伏数智化综合平台:让光伏电站运维更智能、更高效
运维
乌托邦的逃亡者2 小时前
Linux中如何检测IP冲突
linux·运维·tcp/ip
一曦的后花园2 小时前
linux搭建promethes并对接node-exporter指标
linux·运维·服务器
乌托邦的逃亡者3 小时前
CentOS/Openeuler主机中,为一个网卡设置多个IP地址
linux·运维·网络·tcp/ip·centos
拾贰_C3 小时前
【OpenClaw | openai | QQ】 配置QQ qot机器人
运维·人工智能·ubuntu·面试·prompt
桌面运维家3 小时前
服务器进程异常监控:快速定位与排障实战指南
运维·服务器
风曦Kisaki4 小时前
# Linux Shell 编程入门 Day02:条件测试、if 判断、循环与随机数
linux·运维·chrome
木雷坞4 小时前
视觉算法环境 Docker 镜像拉取失败排查
运维·人工智能·docker·容器
郝亚军4 小时前
ubuntu 22.04如何安装libmodbus
运维·服务器·ubuntu
李日灐4 小时前
< 6 > Linux 自动化构建工具:makefile 详解 + 进度条实战小项目
linux·运维·服务器·后端·自动化·进度条·makefile