server {
listen 80;
server_name www.aaa.com;
root /var/www/aaa/dist;
index index.html;
location /api {
add_header 'Access-Control-Allow-Origin' 'http://www.bbb.com';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
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';
proxy_pass http://www.bbb.com/api;
}
location / {
try_files $uri $uri/ /index.html;
}
}
server {
listen 80;
server_name www.bbb.com;
root /var/www/bbb;
index index.html;
location /api {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location / {
try_files $uri $uri/ /index.html;
}
}
标签:Control,index,www,跨域,配置,bbb,Access,header,请求
From: https://www.cnblogs.com/simdot/p/17189883.html