haproxy 如何配置 Access-Control-Allow-Private-Network
时间: 2023-11-05 10:56:24 浏览: 125
要在 HAProxy 中配置 `Access-Control-Allow-Private-Network`,需要使用 `http-response set-header` 选项。以下是一个示例配置:
```
frontend my_frontend
bind *:80
mode http
http-response set-header Access-Control-Allow-Origin http://example.com
http-response set-header Access-Control-Allow-Methods GET, POST, OPTIONS
http-response set-header Access-Control-Allow-Headers Content-Type
http-response set-header Access-Control-Allow-Credentials true
http-response set-header Access-Control-Allow-Private-Network true
default_backend my_backend
backend my_backend
mode http
server web-server1 192.168.0.1:8080
```
在上面的示例中,`http-response set-header Access-Control-Allow-Private-Network true` 配置告诉 HAProxy 允许对私有网络进行访问控制。可以根据需要修改其他选项。
阅读全文