server {
gzip on;
listen 100;
location / {
# 限流
# limit_req zone=limiter;
# 客户端 IP 可以保持同时连接的数量限制
# limit_conn conn_limiter 5;
proxy_pass https://domain.com;
# 允许跨域请求来自指定域名
add_header 'Access-Control-Allow-Origin' 'http://frontend-domain.com';
# 允许的 HTTP 方法
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
# 允许的请求头
add_header 'Access-Control-Allow-Headers' 'Authorization, Origin, X-Requested-With, Content-Type, Accept';
# 代理后保证cookie传递
proxy_cookie_path / /;
# 启用WebSocket支持
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_connect_timeout 120s;
proxy_read_timeout 120s;
proxy_send_timeout 120s;
}
}
nginx 代理 https 服务器接收 http 请求
于 2024-07-24 15:21:26 首次发布