Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在openshift golang应用程序上将http重定向到https?_Openshift_Haproxy - Fatal编程技术网

如何在openshift golang应用程序上将http重定向到https?

如何在openshift golang应用程序上将http重定向到https?,openshift,haproxy,Openshift,Haproxy,我有一个在openshift免费层上运行的缩放golang应用程序。它使用的是位于的自定义cartidge,我想将http重定向到https,我尝试使用.htaccess文件遵循位于的指南,但这不起作用,可能是因为haproxy用作负载平衡器,因此,我的问题是如果可能的话,如何在不接触应用程序代码的情况下将HTTP流量重定向到HTTPS?可能通过更改haproxy.cfg文件,下面是我的`haproxy.cfg文件的样子 defaults mode

我有一个在openshift免费层上运行的缩放golang应用程序。它使用的是位于的自定义cartidge,我想将http重定向到https,我尝试使用
.htaccess
文件遵循位于的指南,但这不起作用,可能是因为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

谢谢。

如果您想强制使用https传输,您可以将以下内容添加到“收听”部分:

重定向方案https代码301如果!{ssl_fc}

但你也需要监听443端口