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

2023-12-26 11:38:16

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;

? ? ? ? client_max_body_size 200M;

? ? ? ? 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;
? ? ? ? ?}
? ? ?}
}

文章来源:https://blog.csdn.net/SongJingzhou/article/details/135163419
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。