【问题标题】:how to redirect http to https on an openshift golang app?如何在 openshift golang 应用程序上将 http 重定向到 https?
【发布时间】:2017-05-16 15:41:29
【问题描述】:

我有一个在 openshift 免费层上运行的扩展 golang 应用程序。它使用位于https://github.com/zolamk/openshift-go 的自定义cartidge,我想将http 重定向到https,我尝试使用.htaccess 文件按照Technical FAQs 的指南进行操作,但这不起作用,可能是因为haproxy 用作负载均衡器,所以我的问题是 如果可能的话,我如何在不触及我的应用程序代码的情况下将 HTTP 流量重定向到 HTTPS? 也许通过更改 haproxy.cfg 文件,这是我的 `haproxy .cfg 文件看起来像

defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    #option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 128

listen stats 127.9.80.3:8080
    mode http
    stats enable
    stats uri /

listen express 127.9.80.2:8080
    cookie GEAR insert indirect nocache
    option httpchk GET /
    http-check expect rstatus 2..|3..|401

    balance leastconn
    server gear-586a4c732d52711f96000127-zolamk ex-std-node847.prod.rhcloud.com:65326 check fall 2 rise 3 inter 2000 cooki$
    server local-gear 127.9.80.1:8080 check fall 2 rise 3 inter 2000 cookie local-586a492489f5cfef6a00002a

谢谢。

【问题讨论】:

    标签: openshift haproxy


    【解决方案1】:

    如果您想强制流量到 https,您可以将以下内容添加到您的收听部分:

    redirect scheme https code 301 if !{ ssl_fc }

    但您还需要监听端口 443

    【讨论】:

      猜你喜欢
      • 2014-07-17
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      • 2011-06-24
      • 2014-10-28
      • 2020-03-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多