{"id":280,"date":"2026-05-28T11:24:33","date_gmt":"2026-05-28T03:24:33","guid":{"rendered":"https:\/\/www.zs1843.cn\/?p=280"},"modified":"2026-05-28T11:31:57","modified_gmt":"2026-05-28T03:31:57","slug":"%e8%ae%b0%e4%b8%80%e6%ac%a1-devtron-%e9%83%a8%e7%bd%b2-502-%e6%8e%92%e9%9a%9c%ef%bc%9a%e4%bb%8e-nginx-%e5%88%b0-alb-%e5%ae%89%e5%85%a8%e7%bb%84","status":"publish","type":"post","link":"https:\/\/www.zs1843.cn\/?p=280","title":{"rendered":"\u8bb0\u4e00\u6b21 Devtron \u90e8\u7f72 502 \u6392\u969c\uff1a\u4ece nginx \u5230 ALB \u5b89\u5168\u7ec4"},"content":{"rendered":"<p class=\"wp-block-paragraph\" style=\"font-size:14px\">\u6700\u8fd1\u516c\u53f8\u5728\u817e\u8baf\u4e91 Devtron \u4e0a\u90e8\u7f72\u4e86\u4e00\u5957 admin \u540e\u53f0\uff0c\u914d\u7f6e\u597d nginx \u540e\u901a\u8fc7\u5185\u7f51\u8def\u7531\u5668 WiFi \u7f51\u5173\u505a\u751f\u4ea7\u73af\u5883\u5185\u6d4b\u3002\u7ed3\u679c\u7535\u8111\u8fde\u4e0a WiFi \u8bbf\u95ee\u9875\u9762\uff0c\u6d4f\u89c8\u5668\u76f4\u63a5\u7529\u4e86\u4e00\u4e2a <strong>502 Gateway<\/strong>\uff0cALB \u53cd\u9988\u7684\u3002\u4e0b\u9762\u8bb0\u5f55\u4e00\u4e0b\u6211\u6392\u67e5\u8fd9\u4e2a\u95ee\u9898\u7684\u5b8c\u6574\u8fc7\u7a0b\u3002<\/p>\n\n<h2 class=\"wp-block-heading\" style=\"font-size:18px\">\u4e00\u3001\u73b0\u8c61<\/h2>\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\">\u9875\u9762\u8bbf\u95ee\u8def\u5f84\u662f\uff1a\u7535\u8111 \u2192 \u5185\u7f51 WiFi \u2192 \u8def\u7531\u5668\u7f51\u5173 \u2192 \u817e\u8baf\u4e91 ALB \u2192 K8s Service \u2192 Pod\uff08nginx \u9759\u6001\u6587\u4ef6\u670d\u52a1\uff09\u3002\u6d4f\u89c8\u5668\u663e\u793a 502\uff0c\u5e76\u4e14\u660e\u786e\u6807\u6ce8\u662f ALB \u8fd4\u56de\u7684\u3002<\/p>\n\n<h2 class=\"wp-block-heading\" style=\"font-size:18px\">\u4e8c\u3001\u7b2c\u4e00\u53cd\u5e94\uff1a\u770b nginx \u914d\u7f6e<\/h2>\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\">\u5148\u68c0\u67e5\u4e86 Pod \u91cc\u7684 nginx.conf\uff0c\u914d\u7f6e\u5982\u4e0b\uff1a<\/p>\n\n<pre class=\"wp-block-code\"><code>server {\n    listen       80;\n    server_name  localhost;\n    root         \/usr\/share\/nginx\/html;\n\n    location = \/healthz {\n        default_type text\/plain;\n        return 200 \"ok\n\";\n    }\n\n    location \/front\/DAdmin {\n        index index.html;\n        try_files $uri \/index.html;\n    }\n\n    location ^~\/front\/static\/ {\n        rewrite ^\/front(\/static\/.*)$ $1 last;\n    }\n\n    location ~*.(gif|jpg|jpeg|png|css|js|ico|svg)$ {\n        root \/usr\/share\/nginx\/html\/;\n    }\n}<\/code><\/pre>\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\">\u4ed4\u7ec6\u4e00\u770b\uff0c\u8fd9\u4e2a nginx \u53ea\u662f\u4e2a<strong>\u7eaf\u9759\u6001\u6587\u4ef6\u670d\u52a1\u5668<\/strong>\uff0c\u6ca1\u6709\u914d\u7f6e\u4efb\u4f55 <code>proxy_pass<\/code> \u53cd\u5411\u4ee3\u7406\u3002\u4e5f\u5c31\u662f\u8bf4\u5b83\u81ea\u5df1\u4e0d\u4ea7\u751f 502\u2014\u2014\u5b83\u53ea\u8d1f\u8d23\u8fd4\u56de\u9759\u6001\u6587\u4ef6\u6216\u8005 404\uff0c\u4e0d\u4f1a\u8fd4\u56de 502\u3002<\/p>\n\n<h2 class=\"wp-block-heading\" style=\"font-size:18px\">\u4e09\u3001502 \u4ece\u54ea\u91cc\u6765\uff1f<\/h2>\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\">\u65e2\u7136 nginx \u672c\u8eab\u4e0d\u4f1a\u4ea7\u751f 502\uff0c\u90a3 502 \u4e00\u5b9a\u662f\u66f4\u4e0a\u6e38\u7684\u7ec4\u4ef6\u8fd4\u56de\u7684\u3002\u7ed3\u5408\u67b6\u6784\u68b3\u7406\u4e86\u4e00\u4e0b\u53ef\u80fd\u7684\u539f\u56e0\uff1a<\/p>\n\n<ul class=\"wp-block-list\" style=\"font-size:14px\"><li><strong>ALB \u5065\u5eb7\u68c0\u67e5\u5931\u8d25<\/strong>\uff1a\u817e\u8baf\u4e91 ALB \u5bf9\u540e\u7aef Pod \u505a\u5065\u5eb7\u68c0\u67e5\uff0c\u5982\u679c\u8fde\u7eed\u5931\u8d25\u5c31\u628a\u8282\u70b9\u6807\u8bb0\u4e3a\u4e0d\u5065\u5eb7\uff0c\u6240\u6709\u8bf7\u6c42\u76f4\u63a5\u8fd4\u56de 502\u3002<\/li><li><strong>Pod \u672a\u5c31\u7eea<\/strong>\uff1aPod \u53ef\u80fd CrashLoopBackOff\u3001ImagePullBackOff\uff0c\u6216\u8005\u5c31\u7eea\u63a2\u9488\u6ca1\u901a\u8fc7\u3002<\/li><li><strong>Service \u4e0e Pod \u5931\u8054<\/strong>\uff1aService \u7684 selector \u6ca1\u5339\u914d\u5230\u4efb\u4f55 Pod\uff0cEndpoint \u4e3a\u7a7a\u3002<\/li><li><strong>\u5185\u7f51\u8def\u7531\u95ee\u9898<\/strong>\uff1aWiFi \u7f51\u5173\u7684 DNS \u89e3\u6790\u53ef\u80fd\u6ca1\u6709\u6b63\u786e\u6307\u5411\u96c6\u7fa4\u5185\u90e8\uff0c\u6216\u8005\u7f51\u7edc\u7b56\u7565\u963b\u6321\u4e86\u6d41\u91cf\u3002<\/li><\/ul>\n\n<h2 class=\"wp-block-heading\" style=\"font-size:18px\">\u56db\u3001\u60f3\u770b\u65e5\u5fd7\u5374\u770b\u4e0d\u5230<\/h2>\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\">\u6211\u4ee5\u4e3a kubectl logs \u80fd\u770b\u5230 nginx \u65e5\u5fd7\uff0c\u7ed3\u679c\u6253\u5f00 Pod \u65e5\u5fd7\u4e00\u7247\u7a7a\u767d\u3002\u56de\u5934\u770b\u914d\u7f6e\u624d\u53cd\u5e94\u8fc7\u6765\uff1a<\/p>\n\n<pre class=\"wp-block-code\"><code>access_log  \/var\/log\/nginx\/access.log  main;\nerror_log   \/var\/log\/nginx\/error.log;<\/code><\/pre>\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\">nginx \u7684\u65e5\u5fd7\u5199\u5230\u4e86<strong>\u5bb9\u5668\u5185\u7684\u6587\u4ef6<\/strong>\uff08\/var\/log\/nginx\/access.log \u548c error.log\uff09\uff0c\u800c\u4e0d\u662f\u6807\u51c6\u8f93\u51fa\u3002kubectl logs \u53ea\u80fd\u770b stdout\/stderr\uff0c\u5f53\u7136\u4ec0\u4e48\u90fd\u770b\u4e0d\u89c1\u3002<\/p>\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\">\u67e5\u65e5\u5fd7\u6709\u4e09\u6761\u8def\uff1a<\/p>\n\n<ol class=\"wp-block-list\" style=\"font-size:14px\"><li><strong>\u8fdb Pod \u76f4\u63a5\u770b<\/strong>\uff1a<code>kubectl exec -it &lt;pod-name&gt; -- cat \/var\/log\/nginx\/access.log<\/code>\uff0c\u6700\u5feb\u6700\u76f4\u63a5\u3002<\/li><li><strong>\u6539\u914d\u7f6e\u8f93\u51fa\u5230 stdout<\/strong>\uff1a\u628a access_log \u6539\u6210 <code>\/dev\/stdout<\/code>\uff0cerror_log \u6539\u6210 <code>\/dev\/stderr<\/code>\uff0c\u4e4b\u540e kubectl logs \u5c31\u80fd\u76f4\u63a5\u770b\u5230\u4e86\u2014\u2014\u8fd9\u662f\u957f\u671f\u65b9\u6848\u3002<\/li><li><strong>\u817e\u8baf\u4e91 CLS \u65e5\u5fd7\u670d\u52a1<\/strong>\uff1a\u5982\u679c Devtron \u96c6\u6210\u4e86\u65e5\u5fd7\u91c7\u96c6\uff0c\u53ef\u4ee5\u5728\u817e\u8baf\u4e91\u63a7\u5236\u53f0 \u2192 \u65e5\u5fd7\u670d\u52a1 \u2192 \u68c0\u7d22\u5206\u6790\u4e2d\u67e5\u8be2\u3002<\/li><\/ol>\n\n<h2 class=\"wp-block-heading\" style=\"font-size:18px\">\u4e94\u3001\u6700\u7ec8\u5b9a\u4f4d\u4e0e\u89e3\u51b3<\/h2>\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\">\u6309\u7167\u4f18\u5148\u7ea7\u4e00\u6b65\u6b65\u6392\u67e5\u4e0b\u6765\uff1a<\/p>\n\n<ol class=\"wp-block-list\" style=\"font-size:14px\"><li><code>kubectl get pods -n &lt;namespace&gt;<\/code> \u2192 \u786e\u8ba4 Pod \u72b6\u6001\u662f Running \u4e14 Ready 1\/1\u3002<\/li><li><code>kubectl get svc,ep -n &lt;namespace&gt;<\/code> \u2192 \u786e\u8ba4 Service \u7684 Endpoint \u4e2d\u6709 Pod IP\u3002<\/li><li>\u5728\u96c6\u7fa4\u5185\u4efb\u610f Pod \u91cc <code>curl http:\/\/&lt;service-name&gt;\/healthz<\/code> \u2192 \u80fd\u901a\uff0c\u8fd4\u56de 200\u3002<\/li><li>\u8fdb nginx Pod <code>kubectl exec<\/code> \u67e5\u770b access.log \u2192 \u53d1\u73b0\u6839\u672c\u6ca1\u6709\u6765\u81ea ALB \u5065\u5eb7\u68c0\u67e5\u7684\u8bf7\u6c42\u8bb0\u5f55\u3002<\/li><\/ol>\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\">\u8d70\u5230\u8fd9\u4e00\u6b65\uff0c\u95ee\u9898\u8303\u56f4\u7f29\u5c0f\u5230\u4e86<strong>ALB \u5230 Pod \u4e4b\u95f4\u7684\u7f51\u7edc\u94fe\u8def<\/strong>\u3002\u6700\u7ec8\u53d1\u73b0\u662f ALB \u7684\u5b89\u5168\u7ec4\u89c4\u5219\u6ca1\u6709\u653e\u884c\u5185\u7f51 WiFi \u7f51\u5173\u7684 IP \u6bb5\uff0c\u5bfc\u81f4\u5065\u5eb7\u68c0\u67e5\u6d41\u91cf\u88ab\u62e6\u622a\uff0cALB \u8ba4\u4e3a\u540e\u7aef\u5168\u90e8\u4e0d\u5065\u5eb7\uff0c\u5bf9\u6240\u6709\u8bf7\u6c42\u76f4\u63a5\u8fd4\u56de 502\u3002<\/p>\n\n<h2 class=\"wp-block-heading\" style=\"font-size:18px\">\u516d\u3001\u603b\u7ed3<\/h2>\n\n<ul class=\"wp-block-list\" style=\"font-size:14px\"><li>\u770b\u5230 502 \u4e0d\u8981\u53ea\u76ef\u7740 nginx\uff0c\u5f97\u770b<strong>\u6574\u6761\u94fe\u8def<\/strong>\u4e0a\u54ea\u4e2a\u73af\u8282\u53ef\u80fd\u62e6\u622a\u4e86\u6d41\u91cf\u3002<\/li><li>nginx \u65e5\u5fd7\u5199\u6587\u4ef6\u800c\u975e stdout \u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u5751\uff0c\u7b2c\u4e00\u65f6\u95f4\u6539\u6210 <code>\/dev\/stdout<\/code> \u80fd\u7701\u5f88\u591a\u4e8b\u3002<\/li><li>\u817e\u8baf\u4e91 ALB \u7684\u5b89\u5168\u7ec4\u89c4\u5219\u5bb9\u6613\u88ab\u5ffd\u7565\u2014\u2014\u52a0\u4e86\u65b0\u6765\u6e90 IP \u6216\u7f51\u6bb5\u540e\u8bb0\u5f97\u540c\u6b65\u66f4\u65b0\u5b89\u5168\u7ec4\u3002<\/li><li>\u6392\u67e5\u987a\u5e8f\uff1aPod \u72b6\u6001 \u2192 Service\/Endpoint \u2192 \u96c6\u7fa4\u5185\u8fde\u901a\u6027 \u2192 ALB \u5065\u5eb7\u68c0\u67e5 \u2192 \u5b89\u5168\u7ec4\/\u7f51\u7edc\u7b56\u7565\u3002<\/li><\/ul>\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\">\u6574\u4e2a\u8fc7\u7a0b\u4e0b\u6765\u6700\u5927\u7684\u611f\u53d7\u662f\uff1a502 \u8fd9\u4e2a\u62a5\u9519\u975e\u5e38&#8221;\u6982\u62ec&#8221;\uff0c\u94fe\u8def\u957f\u7684\u65f6\u5019\u4e0d\u80fd\u9760\u76f4\u89c9\u731c\uff0c\u53ea\u80fd\u4e00\u5c42\u5c42\u6392\u9664\uff0c\u627e\u5230\u771f\u6b63\u65ad\u6389\u7684\u90a3\u4e2a\u73af\u8282\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>\u7535\u8111\u8fdeWiFi\u8bbf\u95ee\u516c\u53f8\u5185\u6d4b\u73af\u5883\u62a5502 Gateway\uff0c\u8bb0\u5f55\u4ecenginx\u914d\u7f6e\u5206\u6790\u5230ALB\u5b89\u5168\u7ec4\u6392\u67e5\u7684\u5b8c\u6574\u8fc7\u7a0b\uff0c\u4ee5\u53canginx\u65e5\u5fd7\u770b\u4e0d\u5230\u7684\u8e29\u5751\u7ecf\u5386\u3002<\/p>\n","protected":false},"author":1,"featured_media":282,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-280","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.zs1843.cn\/index.php?rest_route=\/wp\/v2\/posts\/280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zs1843.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zs1843.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zs1843.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zs1843.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=280"}],"version-history":[{"count":1,"href":"https:\/\/www.zs1843.cn\/index.php?rest_route=\/wp\/v2\/posts\/280\/revisions"}],"predecessor-version":[{"id":283,"href":"https:\/\/www.zs1843.cn\/index.php?rest_route=\/wp\/v2\/posts\/280\/revisions\/283"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.zs1843.cn\/index.php?rest_route=\/wp\/v2\/media\/282"}],"wp:attachment":[{"href":"https:\/\/www.zs1843.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zs1843.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zs1843.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}