您当前的位置:首页 > 计算机 > 服务器 > Nginx

Nginx 做转发解决跨域问题

时间:08-17来源:作者:点击数:
城东书院 www.cdsy.xyz

Nginx 做转发解决跨域问题

server {
    listen       80;
    listen       443  ssl;
    server_name  alidphoto22.testaisegment.com testaisegment.aisegment.com;
    client_max_body_size 512m;
    # ssl                  on;
    ssl_certificate      /app/certs/aisegment.com/current/aisegment.com.crt;
    ssl_certificate_key  /app/certs/aisegment.com/current/aisegment.com.key;

    location / {
        # 做转发到百度
        proxy_pass https://www.baidu.com;
        proxy_redirect off;
        # proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        #解决跨域
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization";
        add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";


    }
}

 

城东书院 www.cdsy.xyz
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐