{"id":18003,"date":"2024-11-18T15:12:37","date_gmt":"2024-11-18T07:12:37","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18003\/"},"modified":"2024-11-18T15:12:37","modified_gmt":"2024-11-18T07:12:37","slug":"nginx403%e9%94%99%e8%af%af%e6%80%8e%e4%b9%88%e8%a7%a3%e5%86%b3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18003\/","title":{"rendered":"nginx403\u9519\u8bef\u600e\u4e48\u89e3\u51b3"},"content":{"rendered":"<blockquote><p>\n  \u670d\u52a1\u5668\u65e0\u6743\u8bbf\u95ee\u6240\u8bf7\u6c42\u7684\u8d44\u6e90\uff0c\u5bfc\u81f4 nginx 403 \u9519\u8bef\u3002\u89e3\u51b3\u65b9\u6cd5\u5305\u62ec\uff1a\u68c0\u67e5\u6587\u4ef6\u6743\u9650\u3002\u68c0\u67e5 .htaccess \u914d\u7f6e\u3002\u68c0\u67e5 nginx \u914d\u7f6e\u3002\u914d\u7f6e selinux \u6743\u9650\u3002\u68c0\u67e5\u9632\u706b\u5899\u89c4\u5219\u3002\u6392\u9664\u5176\u4ed6\u539f\u56e0\uff0c\u5982\u6d4f\u89c8\u5668\u95ee\u9898\u3001\u670d\u52a1\u5668\u6545\u969c\u6216\u5176\u4ed6\u53ef\u80fd\u7684\u9519\u8bef\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/27\/2024052717182355600.jpg\" class=\"aligncenter\" title=\"nginx403\u9519\u8bef\u600e\u4e48\u89e3\u51b3\u63d2\u56fe\" alt=\"nginx403\u9519\u8bef\u600e\u4e48\u89e3\u51b3\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u89e3\u51b3  403 \u9519\u8bef<\/strong><\/p>\n<p>nginx 403 \u9519\u8bef\u8868\u793a\u670d\u52a1\u5668\u62d2\u7edd\u4e86\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\uff0c\u8868\u660e\u5ba2\u6237\u7aef\u65e0\u6743\u8bbf\u95ee\u6240\u8bf7\u6c42\u7684\u8d44\u6e90\u3002\u5bfc\u81f4\u6b64\u9519\u8bef\u7684\u539f\u56e0\u6709\u591a\u79cd\uff0c\u4ee5\u4e0b\u5217\u51fa\u4e86\u4e00\u4e9b\u5e38\u89c1\u539f\u56e0\u548c\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<p><strong>1. \u6587\u4ef6\u6743\u9650\u95ee\u9898<\/strong><\/p>\n<ul>\n<li>\u68c0\u67e5\u8981\u8bbf\u95ee\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u662f\u5426\u5177\u6709\u6b63\u786e\u7684\u8bbf\u95ee\u6743\u9650\u3002<\/li>\n<li>\u4e3a\u6587\u4ef6\u6216\u76ee\u5f55\u6388\u4e88\u5fc5\u8981\u7684\u8bfb\u53d6\u6743\u9650\uff0c\u4f8b\u5982 chmod 644 file.txt\u3002<\/li>\n<\/ul>\n<p><strong>2. .ht \u914d\u7f6e\u9519\u8bef<\/strong><\/p>\n<ul>\n<li>\u68c0\u67e5 .htaccess \u6587\u4ef6\u4e2d\u662f\u5426\u5b58\u5728\u9519\u8bef\u7684\u89c4\u5219\uff0c\u8fd9\u4e9b\u89c4\u5219\u53ef\u80fd\u4f1a\u62d2\u7edd\u5bf9\u7279\u5b9a\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u8bbf\u95ee\u3002<\/li>\n<li>\u68c0\u67e5 .htaccess \u6587\u4ef6\u7684\u8bed\u6cd5\u662f\u5426\u5b58\u5728\u9519\u8bef\uff0c\u5e76\u786e\u4fdd\u5176\u4f7f\u7528\u6b63\u786e\u7684\u6307\u4ee4\u3002<\/li>\n<\/ul>\n<p><strong>3. nginx \u914d\u7f6e\u95ee\u9898<\/strong><\/p>\n<ul>\n<li>\u68c0\u67e5 nginx \u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 location \u5757\u662f\u5426\u6b63\u786e\u914d\u7f6e\uff0c\u5e76\u786e\u4fdd\u5176\u5141\u8bb8\u5bf9\u6240\u8bf7\u6c42\u8d44\u6e90\u7684\u8bbf\u95ee\u3002<\/li>\n<li>\u786e\u8ba4 location \u5757\u4e2d\u7684 allow \u548c deny \u6307\u4ee4\u5df2\u6b63\u786e\u8bbe\u7f6e\uff0c\u5e76\u4e14\u4e0d\u62d2\u7edd\u5bf9\u8d44\u6e90\u7684\u8bbf\u95ee\u3002<\/li>\n<\/ul>\n<p><strong>4. SELinux \u95ee\u9898<\/strong><\/p>\n<ul>\n<li>\u5982\u679c\u670d\u52a1\u5668\u4e0a\u542f\u7528\u4e86 SELinux\uff0c\u5219\u53ef\u80fd\u9700\u8981\u914d\u7f6e SELinux \u6743\u9650\u4ee5\u5141\u8bb8 nginx \u8bbf\u95ee\u6240\u9700\u7684\u8d44\u6e90\u3002<\/li>\n<li>\u68c0\u67e5 SELinux \u65e5\u5fd7\u4ee5\u67e5\u770b\u662f\u5426\u6709\u4e0e nginx 403 \u9519\u8bef\u76f8\u5173\u7684\u6761\u76ee\u3002<\/li>\n<\/ul>\n<p><strong>5. \u9632\u706b\u5899\u95ee\u9898<\/strong><\/p>\n<ul>\n<li>\u68c0\u67e5\u9632\u706b\u5899\u662f\u5426\u963b\u6b62\u4e86\u5bf9\u6240\u8bf7\u6c42\u8d44\u6e90\u7684\u8bbf\u95ee\u3002<\/li>\n<li>\u786e\u8ba4\u9632\u706b\u5899\u89c4\u5219\u5141\u8bb8 nginx \u76d1\u542c\u548c\u63a5\u53d7\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u3002<\/li>\n<\/ul>\n<p><strong>6. \u5176\u4ed6\u539f\u56e0<\/strong><\/p>\n<ul>\n<li>\u5ba2\u6237\u7aef\u6d4f\u89c8\u5668\u53ef\u80fd\u6709\u4f1a\u8bdd\u95ee\u9898\u6216\u7f13\u5b58\u95ee\u9898\u3002\u5c1d\u8bd5\u6e05\u9664\u6d4f\u89c8\u5668\u7684\u7f13\u5b58\u548c cookie\uff0c\u7136\u540e\u91cd\u8bd5\u3002<\/li>\n<li>\u670d\u52a1\u5668\u53ef\u80fd\u9047\u5230\u4e34\u65f6\u6545\u969c\u3002\u5c1d\u8bd5\u7a0d\u540e\u518d\u8bbf\u95ee\u8d44\u6e90\u3002<\/li>\n<li>\u8054\u7cfb\u670d\u52a1\u5668\u7ba1\u7406\u5458\u4ee5\u6392\u9664\u5176\u4ed6\u53ef\u80fd\u7684\u539f\u56e0\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f403\u9519\u8bef\u600e\u4e48\u89e3\u51b3\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u670d\u52a1\u5668\u65e0\u6743\u8bbf\u95ee\u6240\u8bf7\u6c42\u7684\u8d44\u6e90\uff0c\u5bfc\u81f4 nginx 403 \u9519\u8bef\u3002\u89e3\u51b3\u65b9\u6cd5\u5305\u62ec\uff1a\u68c0\u67e5\u6587\u4ef6\u6743\u9650\u3002\u68c0\u67e5 .htaccess \u914d\u7f6e\u3002\u68c0\u67e5 nginx \u914d\u7f6e\u3002\u914d\u7f6e selinux \u6743\u9650\u3002\u68c0\u67e5\u9632\u706b\u5899\u89c4\u5219\u3002\u6392\u9664\u5176\u4ed6\u539f\u56e0\uff0c\u5982\u6d4f\u89c8\u5668\u95ee\u9898\u3001\u670d\u52a1\u5668\u6545\u969c\u6216\u5176\u4ed6\u53ef\u80fd\u7684\u9519\u8bef\u3002 \u5982\u4f55\u89e3\u51b3 403 \u9519\u8bef nginx 403 \u9519\u8bef\u8868\u793a\u670d\u52a1\u5668\u62d2\u7edd\u4e86\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\uff0c\u8868\u660e\u5ba2\u6237\u7aef\u65e0\u6743\u8bbf\u95ee\u6240\u8bf7\u6c42\u7684\u8d44\u6e90\u3002\u5bfc\u81f4\u6b64\u9519\u8bef\u7684\u539f\u56e0\u6709\u591a\u79cd\uff0c\u4ee5\u4e0b\u5217\u51fa\u4e86\u4e00\u4e9b\u5e38\u89c1\u539f\u56e0\u548c\u89e3\u51b3\u65b9\u6cd5\uff1a 1. \u6587\u4ef6\u6743\u9650\u95ee\u9898 \u68c0\u67e5\u8981\u8bbf\u95ee\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u662f\u5426\u5177\u6709\u6b63\u786e\u7684\u8bbf\u95ee\u6743\u9650\u3002 \u4e3a\u6587\u4ef6\u6216\u76ee\u5f55\u6388\u4e88\u5fc5\u8981\u7684\u8bfb\u53d6\u6743\u9650\uff0c\u4f8b\u5982 chmod 644 file.txt\u3002 2. .ht \u914d\u7f6e\u9519\u8bef \u68c0\u67e5 .htaccess \u6587\u4ef6\u4e2d\u662f\u5426\u5b58\u5728\u9519\u8bef\u7684\u89c4\u5219\uff0c\u8fd9\u4e9b\u89c4\u5219\u53ef\u80fd\u4f1a\u62d2\u7edd\u5bf9\u7279\u5b9a\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u8bbf\u95ee\u3002 \u68c0\u67e5 .htaccess \u6587\u4ef6\u7684\u8bed\u6cd5\u662f\u5426\u5b58\u5728\u9519\u8bef\uff0c\u5e76\u786e\u4fdd\u5176\u4f7f\u7528\u6b63\u786e\u7684\u6307\u4ee4\u3002 3. nginx \u914d\u7f6e\u95ee\u9898 \u68c0\u67e5 nginx \u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 location \u5757\u662f\u5426\u6b63\u786e\u914d\u7f6e\uff0c\u5e76\u786e\u4fdd\u5176\u5141\u8bb8\u5bf9\u6240\u8bf7\u6c42\u8d44\u6e90\u7684\u8bbf\u95ee\u3002 \u786e\u8ba4 location \u5757\u4e2d\u7684 allow \u548c deny \u6307\u4ee4\u5df2\u6b63\u786e\u8bbe\u7f6e\uff0c\u5e76\u4e14\u4e0d\u62d2\u7edd\u5bf9\u8d44\u6e90\u7684\u8bbf\u95ee\u3002 4. SELinux \u95ee\u9898 \u5982\u679c\u670d\u52a1\u5668\u4e0a\u542f\u7528\u4e86 SELinux\uff0c\u5219\u53ef\u80fd\u9700\u8981\u914d\u7f6e SELinux \u6743\u9650\u4ee5\u5141\u8bb8 nginx [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-18003","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18003","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=18003"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18003\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}