大网数据广告活动
服务器运维问答

haproxy exclude a url from https redirection

· 52CE 我爱测

I am beginner with haproxy and trying to do same basic redirection with haproxy I have 2 sites www.test.com -> want to this to be redirected to https www.test.com/helpsub -> Should not redirect to https and remain on http Is this…

问题原文

原帖链接 · user305414 · CC BY-SA 3.0

I am beginner with haproxy and trying to do same basic redirection with haproxy

I have 2 sites

  1. www.test.com -> want to this to be redirected to https
  2. www.test.com/helpsub -> Should not redirect to https and remain on http

Is this possible ?

Best Regards,

W

已采纳解答

原帖链接 · Mick Switser · CC BY-SA 4.0

Assuming you are using the 1.5 version of HAProxy.

To redirect to https can be done via the redirect scheme directive. This directive has an optional conditions list, so you could set up an ACL for this purpose.

For instance to set up an acl to match the /helpsub path, you could have:

acl helpsub path_beg /helpsub

And to then do the redirect to https for everything, except the helpsub (and of course only when the connection is not yet via ssl) you could have:

redirect scheme https if !{ ssl_fc } !helpsub

The ! sign means not matching, so basically this reads as:

redirect the request to the https scheme, if you are not on an ssl connection and the path does not start with /helpsub.

Reference.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-08-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。