2017-01-02 48 views
0

我有一個縮放golang應用程序運行在openshift免費層。它使用位於https://github.com/zolamk/openshift-go的自定義cartidge,我想將http重定向到https,我嘗試使用.htaccess文件跟隨在Technical FAQs的指南,但那不起作用,可能是因爲haproxy用作負載平衡器,所以我的問題是如果可能,我如何在不觸摸我的應用程序代碼的情況下將HTTP流量重定向到HTTPS?可能通過改變haproxy.cfg文件,這裏是我的`haproxy.cfg文件看起來像如何在openshift golang應用中將http重定向到https?

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 

感謝。

回答

0

如果要強制流量HTTPS您可以添加以下到您的收聽部分:

redirect scheme https code 301 if !{ ssl_fc }

但你需要將偵聽端口443藏漢