💻

haproxy v1.5 でHSTSを有効にする。
January 12, 2022February 20, 2024
#Develop#haproxy#SSL

haproxy を HTST に対応しようと思って config を追加したらエラーがでた

追加した設定

http-response set-header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload;"

エラー

* Reloading haproxy haproxy
[ALERT] 011/191557 (13982) : parsing [/etc/haproxy/haproxy.cfg:25]: 'http-response set-header' expects exactly 2 arguments.
[ALERT] 011/191557 (13982) : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg

2arguments 入れてるじゃんと思ってググったところ haproxy v1.5 系ではダブルクオーテーションで括れないみたいだった。

haproxy v1.5 で HTST を設定するときの config

ダブルクオーテーションで囲うのではなくスペースをエスケープする。

http-response set-header Strict-Transport-Security max-age=31536000;\ includeSubDomains;\ preload;

これでバッチリリスタートできた

image-20220112212308777

設定的にも OK

参考

Frame-ancestors directive issues

Thank you for your quick response. However, haproxy does not start with that syntax. Error log says ’http-response set-header’ expects exactly 2 arguments"

HAProxy community

Frame-ancestors directive issues

おしまい

sakakinox

Written by sakakinox
Server enginier

Copyright © sakakinox.net 2021-2026.