在 Admin Router 前配置 HAProxy

    使用 HAProxy 为 DC/OS Admin Router 设置 HTTP 代理

    HTTP 代理必须执行即时 HTTP 请求和响应标头修改,因为 DC/OS 不知道用户代理程序用于寻址 HTTP 代理的自定义主机名和端口。

    1. 安装 HAProxy 。

    2. 您可以使用代理 IP 地址 DNS 条目找到您的任务 IP。

      • :任务名称。
      • framework_name:框架名称,如果您不确定,则可能是 marathon
      1. global
      2. daemon
      3. log 127.0.0.1 local0
      4. log 127.0.0.1 local1 notice
      5. maxconn 20000
      6. pidfile /var/run/haproxy.pid
      7. defaults
      8. log global
      9. option dontlog-normal
      10. mode http
      11. retries 3
      12. maxconn 20000
      13. timeout connect 5000
      14. timeout client 50000
      15. timeout server 50000
      16. frontend http
      17. # Bind on port 9090. HAProxy will listen on port 9090 on each
      18. # available network for new HTTP connections.
      19. bind 0.0.0.0:9090
      20. # Specify your own server certificate chain and associated private key.
      21. # See https://cbonte.github.io/haproxy-dconv/configuration-1.6.html#5.1-crt
      22. # bind *:9091 ssl crt /path/to/browser-trusted.crt
      23. #
      24. # Name of backend configuration for DC/OS.
      25. # so that its value is accessible during response processing.
      26. # Note: RFC 7230 requires clients to send the Host header and
      27. # specifies it to contain both, host and port information.
      28. http-request set-var(txn.request_host_header) req.hdr(Host)
      29. # Overwrite Host header to 'dcoshost'. This makes the Location
      30. # header in DC/OS Admin Router upstream responses contain a
      31. # predictable hostname (NGINX uses this header value when
      32. # constructing absolute redirect URLs). That value is used
      33. # in the response Location header rewrite logic (see regular
      34. # expression-based rewrite in the backend section below).
      35. http-request set-header Host dcoshost
      36. backend dcos
      37. # Option 1: use TLS-encrypted communication with DC/OS Admin Router and
      38. # perform server certificate verification (including hostname verification).
      39. # If you are using the community-supported version of DC/OS, you must
      40. # configure Admin Router with a custom TLS server certificate, see
      41. # /mesosphere/dcos/2.1/administering-clusters/. This step
      42. # is not required for DC/OS Enterprise.
      43. #
      44. # Explanation for the parameters in the following `server` definition line:
      45. #
      46. # 1.2.3.4:443
      47. #
      48. # IP address and port that HAProxy uses to connect to DC/OS Admin
      49. # Router. This needs to be adjusted to your setup.
      50. #
      51. #
      52. # Instruct HAProxy to use TLS, and to error out if server certificate
      53. # verification fails.
      54. #
      55. # ca-file dcos-ca.crt
      56. #
      57. # The local file `dcos-ca.crt` is expected to contain the CA certificate
      58. # that Admin Router's certificate will be verified against. It must be
      59. # retrieved out-of-band (on Mesosphere DC/OS Enterprise this can be
      60. # obtained via https://dcoshost/ca/dcos-ca.crt)
      61. #
      62. # verifyhost frontend-xxx.eu-central-1.elb.amazonaws.com
      63. #
      64. # When verifying the TLS certificate presented by DC/OS Admin Router,
      65. # perform hostname verification using the hostname specified here
      66. # (expect the server certificate to contain a DNSName SAN that is
      67. # equivalent to the hostname defined here). The hostname shown here is
      68. # just an example and needs to be adjusted to your setup.
      69. server dcos-1 1.2.3.4:443 ssl verify required ca-file dcos-ca.crt verifyhost frontend-xxx.eu-central-1.elb.amazonaws.com
      70. # Option 2: use TLS-encrypted communication with DC/OS Admin Router, but do
      71. # not perform server certificate verification (warning: this is insecure, and
      72. # we hope that you know what you are doing).
      73. # server dcos-1 1.2.3.4:443 ssl verify none
      74. #
      75. # Rewrite response Location header if it contains an absolute URL
      76. # pointing to the 'dcoshost' host: replace 'dcoshost' with original
      77. # request Host header (containing hostname and port).
    3. 使用这些设置启动 HAProxy。