servicestack - 负载均衡器上终止 HTTPS 时的 ServiceStack 安全 cookie
问题描述
在 ServiceStack 中,该HostConfig
标志UseSecureCookies = true
将在通过 HTTPS 传输时将 cookie 标记为安全。
然而,在现实世界中,通常在负载均衡器处终止 SSL,然后在内部使用 HTTP(即Internet --https--> LB --http--> application
)
在这种情况下如何实现安全的 HTTPS cookie?
解决方案
安全 cookie只能通过 HTTPS 传输,ServiceStack 仍将在 SSL 终止代理之后发出安全 cookie,前提是它正确设置了X-Forwarded-Proto: https
下游 HTTP 标头。
例如,这里是SSL Terminated nginx 反向代理的典型示例:
server {
listen 80;
server_name my-app.org;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_cache_bypass $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_ignore_client_abort off;
proxy_intercept_errors on;
client_max_body_size 500m;
}
}
推荐阅读
- python - mean_validation_score 给出一个 AttributeError
- javascript - 是否有记录 Jest/Puppeteer 测试套件的传统方法?
- linux - 使用 ASAN 时如何修复错误“无法运行 C 编译程序”
- python - 为什么 tkinter 按钮中的图片显示全黑?
- node.js - ReferenceError:未定义猫鼬。- 当我在 Chrome DevTools 上运行 jest 调试时
- php - 为指定类别的产品添加文本挂钩
- windows - 在 Docker 构建期间访问 Gitlab CI 变量
- sapper - 如何使用 svelte/sapper 进行页面转换
- swift - 如何从 UnsafeMutablePointer 获取 CVPixelBuffer 句柄
在斯威夫特? - r - 使用循环更改函数名称和过滤器值