avatar

nk

学习 思考 坚持 平静

  • 首页
  • 关于
Home Nginx配置跨越支持
文章

Nginx配置跨越支持

Posted 2024-03-19 Updated 2024-03- 19
By nk
5~6 min read

Niginx 配置 跨越支持

nginx.conf

nginx 主配置文件

    map $http_origin $allow_origin {
        default "";
        ~^https?://[^/]*\.realme\.net(:[0-9]+)?$ $http_origin;
        ~^https?://[^/]*\.realme\.com(:[0-9]+)?$ $http_origin;
    }

ChatGPT4 对此的解释

image-sadnk.png web.conf

server 块中配置如下

 add_header 'Access-Control-Allow-Origin' $allow_origin always;
 add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
 add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
 add_header 'Access-Control-Allow-Credentials' 'true' always;
Linux
Nginx
License:  CC BY 4.0
Share

Further Reading

Mar 19, 2024

Nginx配置跨越支持

Feb 23, 2024

小鸡的自我救赎: Alpine Linux

OLDER

每日面试题: 2024-3-21

NEWER

小鸡的自我救赎: Alpine Linux

Recently Updated

  • 拥抱云原生:Dockerfile 的多阶段构建
  • 拥抱云原生:Dockerfile
  • 拥抱云原生:Docker文件系统
  • 拥抱云原生:Docker 指令小析
  • 拥抱云原生:起始

Trending Tags

Python Nginx 工作报告 云计算 云原生 Alpine Linux Docker Spring Linux 面试智慧

Contents

©2026 nk. Some rights reserved.

Using the Halo theme Chirpy