2017-07-05 8 views
1

私はkubernetes経由でAWS上でtraefikを実行しています。私のhttp => httpsリダイレクト設定を除いて、すべて動作します。Traefik httpsリダイレクト(kubernetes展開経由)

私は以下のKubernetes展開+サービスの構成では、次の.tomlファイル

defaultEntryPoints = ["http", "https"] 

[entryPoints] 
    [entryPoints.http] 
    address = ":80" 
    [entryPoints.http.redirect] 
     entryPoint = "https" 

を持っています。

> curl http://www.myserver.com 
curl: (52) Empty reply from server 

Kubernetes設定ファイルを:

kind: Deployment 
apiVersion: extensions/v1beta1 
metadata: 
    name: traefik-proxy 
    labels: 
    app: traefik-proxy 
    tier: proxy 
spec: 
    replicas: 1 
    selector: 
    matchLabels: 
     app: traefik-proxy 
     tier: proxy 
    template: 
    metadata: 
     labels: 
     app: traefik-proxy 
     tier: proxy 
    spec: 
     terminationGracePeriodSeconds: 60 

     # kubectl create configmap traefik-conf --from-file=./conf/k8s/traefik.toml 
     volumes: 
     - name: config 
     configMap: 
      name: traefik-conf 

     containers: 
     - image: traefik:v1.2.0-rc1-alpine 
     name: traefik-proxy 
     resources: 
      limits: 
      cpu: "200m" 
      memory: "30Mi" 
      requests: 
      cpu: "100m" 
      memory: "20Mi" 
     volumeMounts: 
     - mountPath: "/conf" 
      name: config 
     ports: 
     - containerPort: 80 
      hostPort: 80 
      name: traefik-proxy 
     - containerPort: 8080 
      name: traefik-ui 
     args: 
     - --configFile=/conf/traefik.toml 
     - --kubernetes 
     - --web 
--- 
apiVersion: v1 
kind: Service 
metadata: 
    name: traefik-proxy 
    annotations: 
    # SSL certificate. 
    # https://console.aws.amazon.com/acm (alienlabs.io) 
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn:aws:acm:us-east-1:861694698401:certificate/28204a9f-69ec-424d-8f56-ac085b7bdad8" 
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "http" 
spec: 
    type: LoadBalancer 
    selector: 
    app: traefik-proxy 
    tier: proxy 
    ports: 
    - port: 80 
    targetPort: 80 
    name: http 
    - port: 443 
    targetPort: 80 
    name: https 

答えて

0

あなたは少し異なり、あなたのエントリポイントを述べるたい:

defaultEntryPoints = ["http","https"] 
[entryPoints] 
    [entryPoints.http] 
    address = ":80" 
    [entryPoints.http.redirect] 
    regex = "^http://(.*)" 
    replacement = "https://$1" 
    [entryPoints.https] 
    address = ":443" 
+0

ありがとう。私はこれを試したが、https://myserver.comリクエストはhttp://myserver.com:443にリダイレクトされ、ERR_EMPTY_RESPONSEが返される。あなたのk8の設定は上記の鉱山と似ていますか? ELBが終了するようにAWS証明書を使用していますか? – rsb

0

マイtraefik.toml

HTTPS要求が返す作業ファイルを要求しますが、HTTP configはCoreyに似ていますが、少しシンプルです。キャッチオールリダイレクトhttphttpsにうまくいきます。

defaultEntryPoints = ["http","https"] 
[entryPoints] 
    [entryPoints.http] 
    address = ":80" 
    [entryPoints.http.redirect] 
     entryPoint = "https" 
    [entryPoints.https] 
    address = ":443" 
+0

ありがとうEugene - 下のCoreyへの私の反応を見てください。 – rsb

関連する問題