【问题标题】:Adding /healthz to NGINX Docker image将 /healthz 添加到 NGINX Docker 映像
【发布时间】:2020-01-21 21:37:53
【问题描述】:

我正在尝试部署 nginx docker 映像。我需要创建一个端点供我的就绪探针使用,这应该是一个简单的/healthz 端点,它返回 200 / OK。

我已经尝试过以下方法,但这会导致浏览器下载包含响应的文件而不是将其呈现为文档。

server {
    listen       80;
    server_name  localhost;

    location /healthz {
        return 200 "OK\n";
    }

    location / {

        root   /usr/share/nginx/html;
        index  index.html index.htm;
        try_files $uri /index.html;                 
    }

    # redirect server error pages
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

}

【问题讨论】:

    标签: docker nginx google-kubernetes-engine nginx-config


    【解决方案1】:

    默认内容类型为application/octet-stream

    尝试添加add_header Content-Type text/plain;

    location / {
        add_header Content-Type text/plain;
        return 200 'OK';
    }
    

    【讨论】:

      猜你喜欢
      • 2018-09-23
      • 2020-01-31
      • 2021-12-11
      • 1970-01-01
      • 2020-01-15
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多