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

Prevent HAProxy from redirecting HTTP to HTTPS

· 52CE 我爱测

I'm using HAproxy to load balance requests between Apache servers. I'm trying to disable HTTPS for a special use case (serving of kickstart files), and I'm using port 8000 to do this. I have an HAProxy configuration that looks ro…

问题原文

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

I'm using HAproxy to load balance requests between Apache servers. I'm trying to disable HTTPS for a special use case (serving of kickstart files), and I'm using port 8000 to do this. I have an HAProxy configuration that looks roughly like this (some configuration has been omitted):

frontend provision_frontend_b
        bind 10.1.1.1:8000
        mode http
        default_backend provision_backendb


backend provision_backendb
        mode http
        server server1 127.0.0.1:8000 weight 1
        server server2 10.1.1.2:8000 weight 1

I want HAProxy to redirect requests made to the external IP on port 8000, to the loopback address on port 8000, where I have Apache listening. Apache is configured to serve static files over HTTP.

Strangely, when I hit the server from my browser using the frontend's DNS name: http://myhost.mydomain:8000, I get redirected to HTTPS and an SSL certificate error. When I try with the IP, http://10.1.1.1:8000, it works (and does not redirect to HTTPS).

Is there any reason why HAProxy would do this? It doesn't seem to be Apache, as I've configured HAProxy to redirect to other HTTP-only Apache servers, and still receive this error.

The only thing I see in the HAProxy config is another frontend configured to redirect to SSL:

frontend http_frontend
        bind :80
        mode http
        redirect scheme https if !{ ssl_fc }

However, it is listening on a different port. I attempted to comment the redirect out, and it did not resolve the issue.

已采纳解答

原帖链接 · Gaurav Pundir · CC BY-SA 3.0

No , Its not Haproxy. Haproxy has nothing to do with your https redirection. Looks like the myhost.mydomain was cached in your web browser for an internal 307 redirect. Which will always send your traffic in https mode. Clear out your cache and cookies in the browser, It should work. I am not sure if you could do anything from the server side, I once faced this issue, I tried forcefully redirecting to http scheme but then to many redirects error came up.

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

资料来源与适用范围

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

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

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