server {
listen 80;
server_name web.ccc.com;
location /
{
root /html;
}
}
server {
listen 80;
server_name api.ccc.com;
location /
{
proxy_pass http://localhost:9090;
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods "GET, OPTIONS, POST, GET";
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
proxy_max_temp_file_size 0;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
web.ccc.com 是放静态资源的
api.ccc.com 是nutz的 对外提供的api
但是按照上面配置,存在跨域问题
加入
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods "GET, OPTIONS, POST, GET";
还是不行,能否帮忙看看是哪里设置错误?