nginx代理ceph网关,解决跨域访问

user  root;
worker_processes  2;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    sendfile        on;

    gzip on;
    gzip_buffers 4 8k;
    gzip_min_length 2048;
    gzip_types application/javascript application/xml application/json text/plain text/css;
    gzip_proxied off;

    server {
        listen       81;
        server_name  192.168.0.88;

        access_log   logs/81_access.log main buffer=32k flush=5s;
        error_log    logs/81_error.log;
        location / {
            add_header 'Access-Control-Allow-Origin' '$http_origin' always;
            add_header 'Access-Control-Allow-Methods' 'GET, POST,PUT, OPTIONS' always;
            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
            add_header 'Access-Control-Allow-Credentials' 'true' always;
            add_header 'Access-Control-Max-Age' 86400 always;
            if ($request_method = 'OPTIONS') {
            return 204;
        }
            proxy_pass http://192.168.0.88:7480$1;

            proxy_set_header host $http_host;
         }
     }
}

你可能感兴趣的:(nginx,ceph跨域,cors)