{"id":253901,"date":"2022-10-07T10:07:27","date_gmt":"2022-10-07T02:07:27","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=253901"},"modified":"2022-09-28T11:08:12","modified_gmt":"2022-09-28T03:08:12","slug":"nginx-six-java","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/nginx-six-java.html","title":{"rendered":"\u670d\u52a1\u5668nginx\u6743\u9650\u88ab\u62d2\u7edd\u7684\u89e3\u51b3\u65b9\u6cd5"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4e3a\u5927\u5bb6\u4ecb\u7ecd\u4e86\u670d\u52a1\u5668nginx\u6743\u9650\u88ab\u62d2\u7edd\u89e3\u51b3\u6848\u4f8b\uff0c\u6709\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u501f\u9274\u53c2\u8003\u4e0b\uff0c\u5e0c\u671b\u80fd\u591f\u6709\u6240\u5e2e\u52a9\uff0c\u795d\u5927\u5bb6\u591a\u591a\u8fdb\u6b65\uff0c\u65e9\u65e5\u5347\u804c\u52a0\u85aa<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u4e3b\u9898<\/strong><\/div>\n

\u73b0\u5728\u670d\u52a1\u5668\u8d44\u4ea7\u591a\u79cd\u591a\u6837,\u4e60\u60ef\u4e86\u963f\u91cc\u4e91\u7684\u4fdd\u59c6\u5f0f\u914d\u7f6e,\u5176\u4ed6\u79c1\u6709\u4e91\u7684\u88c5\u673a\u914d\u7f6e\u5404\u6709\u5404\u7684\u98ce\u683c,\u4eca\u5929\u804a\u804anginx\u7a81\u53d1\u72b6\u51b5,\u6743\u9650\u88ab\u62d2\u7edd\u7684\u95ee\u9898\u76f8\u5173\u6392\u67e5\u8fc7\u7a0b\u53ca\u89e3\u51b3\u529e\u6cd5\u3002<\/p>\n

\u7ecf\u8fc7<\/strong><\/div>\n

\u672c\u6765\u4ee5\u4e3a\u662f\u4e2a\u76f8\u5f53\u6109\u5feb\u7684\u8fc7\u7a0b,\u4e0a\u4e00\u7bc7\u8bf4\u660e\u4e86\u670d\u52a1\u5668\u5b89\u5168\u539f\u56e0,\u76f8\u5173\u7f51\u7edc\u73af\u5883\u7684\u6392\u67e5,\u8fd9\u6b21\u7ee7\u7eed\u8bf4\u4e00\u8bf4\u5173\u4e8enginx\u4ee3\u7406\u9047\u5230\u7684\u95ee\u9898 \u5148\u8bf4\u8bf4\u8868\u8c61,\u539f\u672c\u7684\u670d\u52a1\u5668\u5df2\u7ecf\u9884\u88c5\u4e86nginx\u627e\u5230\u76f8\u5173\u914d\u7f6e\u8fdb\u884c\u8bbe\u7f6e\u4ee5\u540e,\u8fd8\u662f\u65e0\u6cd5\u8bbf\u95ee<\/p>\n

ps -aux | grep nginx  \/\/\u67e5\u770bnginx\u8fdb\u7a0b\u60c5\u51b5\r\nnetstat -anp | grep :80 \/\/\u67e5\u770b\u76f8\u5173\u7aef\u53e3\u5df2\u6b63\u5e38\u542f\u52a8<\/pre>\n

\u5728\u786e\u5b9a\u76f8\u5173nginx\u5df2\u7ecf\u542f\u52a8\u7684\u60c5\u51b5\u4e0b,\u53d1\u73b0\u4ee3\u7406\u7684\u7f51\u7ad9\u65e0\u6cd5\u8bbf\u95ee,\u63a5\u53e3\u76f8\u5173\u7684500\u53ef\u4ee5\u6b63\u5e38\u8fd4\u56de<\/p>\n

curl 127.0.0.1:80\/web \/\/\u9a8c\u8bc1\u8bbf\u95ee\u5185\u5bb9\r\n\/var\/log\/nginx\/      \/\/\u67e5\u770b\u76f8\u5173\u65e5\u5fd7\u4fe1\u606f<\/pre>\n

\u6216\u8005\u7528\u4e00\u4e0b\u547d\u4ee4\u67e5\u770b<\/p>\n

systemctl status nginx.service -l<\/pre>\n

\u7ecf\u8fc7\u5bf9\u9519\u8bef\u65e5\u5fd7\u7684\u6392\u67e5\u53d1\u73b0\u8bbf\u95ee\u7f51\u7ad9\u9759\u6001\u7f51\u9875\u65f6\uff0c\u76f8\u5173\u5f02\u5e38\u4e3a 'Permission denied'\uff0c\u8fd9\u79cd\u60c5\u51b5\u67e5\u4e86\u5f88\u591a\u8d44\u6599,<\/p>\n

\u6700\u7ec8\u89e3\u51b3\u529e\u6cd5<\/strong><\/div>\n

chcon\u547d\u4ee4\u662f\u4fee\u6539\u5bf9\u8c61\uff08\u6587\u4ef6\uff09\u7684\u5b89\u5168\u4e0a\u4e0b\u6587\uff0c\u6bd4\u5982\uff1a\u7528\u6237\u3001\u89d2\u8272\u3001\u7c7b\u578b\u3001\u5b89\u5168\u7ea7\u522b\u3002\u4e5f\u5c31\u662f\u5c06\u6bcf\u4e2a\u6587\u4ef6\u7684\u5b89\u5168\u73af\u5883\u53d8\u66f4\u81f3\u6307\u5b9a\u73af\u5883\u3002<\/p>\n

SeLinux\u6982\u5ff5\u4f5c\u7528<\/strong><\/span><\/div>\n

\u7cfb\u7edf\u5f00\u542f\u4e86SeLinux\uff0c\u53d7\u5230\u4e86SeLinux\u7684\u9650\u5236 \u5148\u8bf4\u8bf4SeLinux\u7684\u6982\u5ff5\u548c\u4f5c\u7528<\/p>\n

selinux(Security-Enhanced Linux)\u5b89\u5168\u589e\u5f3a\u578blinux\uff0c\u662f\u4e00\u4e2aLinux\u5185\u6838\u6a21\u5757\uff0c\u4e5f\u662fLinux\u7684\u4e00\u4e2a\u5b89\u5168\u5b50\u7cfb\u7edf\u3002<\/p>\n

\u4e09\u79cd\u6a21\u5f0f\uff1a<\/p>\n

Enforcing\uff1a\u5f3a\u5236\u6a21\u5f0f\uff0c\u5728selinux\u8fd0\u4f5c\u65f6\uff0c\u5df2\u7ecf\u5f00\u59cb\u9650\u5236domain\/type\u3002<\/p>\n

permissive: \u8b66\u544a\u6a21\u5f0f\uff0c\u5728selinux\u8fd0\u4f5c\u65f6\uff0c\u4f1a\u6709\u8b66\u544a\u8baf\u606f\uff0c\u4f46\u4e0d\u4f1a\u9650\u5236domain\/type\u7684\u5b58\u53d6\u3002<\/p>\n

disabled: \u5173\u95ed\u6a21\u5f0f\u3002<\/p>\n

\u53ef\u7528getenforce\u67e5\u770bselinux\u72b6\u6001<\/p>\n

selinux\u5bf9\u6587\u4ef6\u7684\u4f5c\u7528\uff1a<\/p>\n

\u5f53\u5f00\u542fselinux\u540e\uff0cselinux\u4f1a\u7ed9\u6bcf\u4e2a\u6587\u4ef6\u52a0\u8f7d\u6807\u7b7econtext,\u5b89\u5168\u4e0a\u4e0b\u6587\u5fc5\u987b\u914d\u5bf9\uff0c\u5426\u5219\u6587\u4ef6\u4e0d\u80fd\u8bbf\u95ee \u67e5\u770b\u4e0bselinux\u7b56\u7565\u914d\u7f6e(\u627e\u5230\u80fd\u751f\u6548\u7684\u6587\u4ef6\u5939\u548c\u5f53\u524d\u53d1\u5e03\u7684\u6587\u4ef6\u5939\u6743\u9650\u533a\u522b,\u8fdb\u884c\u76f8\u5173\u7684\u8bbe\u7f6e)<\/p>\n

ls -lrtZ \/usr\/share\/nginx\/html<\/pre>\n
chcon -R -t httpd_sys_content_t  \/home\/xx\/\r\nnginx -s reload<\/pre>\n

\u6700\u7ec8\u89e3\u51b3\u4e86\u76f8\u5173\u95ee\u9898\uff0c\u4ee5\u4e0b\u662f\u8fdb\u884c\u7684\u4e00\u4e9b\u65e0\u6548\u5c1d\u8bd5,\u53ef\u80fd\u67d0\u4e9b\u670d\u52a1\u5668\u73af\u5883\u53ef\u4ee5\u751f\u6548<\/p>\n

\u65e0\u6548\u5c1d\u8bd5<\/strong><\/span><\/div>\n

\u53d1\u5e03\u6587\u4ef6\u5939\u6388\u6743\u7684\u5c1d\u8bd5<\/p>\n

sudo chmod o+x \/home\/xxx\/<\/pre>\n

\u5173\u4e8enginx\u914d\u7f6e\u6587\u4ef6\/etc\/nginx\/nginx.conf,\u6307\u5b9a\u7528\u6237\u7684\u5c1d\u8bd5,\u4f9d\u7136\u65e0\u6548<\/p>\n

user nginx; ->\u66f4\u6539\u4e3a user root\r\nnginx -s reload<\/pre>\n

\u5176\u4ed6\u6bd4\u8f83\u7c97\u66b4\u4e00\u70b9\u513f\u7684\u6559\u7a0b\u8981\u4e48\u76f4\u63a5\u5173\u95ed\u6216\u4e34\u65f6\u6027\u89e3\u51b3<\/p>\n

setenforce 0 ##\u8bbe\u7f6eSELinux \u6210\u4e3apermissive\u6a21\u5f0f\r\n #setenforce 1 ##\u8bbe\u7f6eSELinux \u6210\u4e3aenforcing\u6a21\u5f0f<\/pre>\n

\u6c38\u4e45\u751f\u6548 \u4fee\u6539\/etc\/selinux\/config\u6587\u4ef6\uff0c\u5c06SELINUX=enforcing\u6539\u4e3aSELINUX=disabled\uff0c\u91cd\u542f\u673a\u5668 \u6ca1\u6562\u5173\u95ed\u8fd9\u4e2a\u5b89\u5168\u7b56\u7565<\/p>\n

\u603b\u7ed3<\/strong><\/div>\n

\u6211\u8fd9\u79cd\u5438\u5f15bug\u7684\u4f53\u8d28\uff0c\u4e0d\u914d\u987a\u987a\u5229\u5229\u5b8c\u6210\u4efb\u52a1\u3001\u670d\u52a1\u5668\u7684\u95ee\u9898\u5728\u6700\u5f00\u59cb\u4e0a\u73ed\u65f6,windows\u73af\u5883\u4e0b\u7ecf\u5e38\u6700\u5934\u75bc\u7684\u5c31\u662f\u670d\u52a1\u5668\u73af\u5883\u7684\u9884\u88c5\u4e0a\u7ebf\uff0c\u5e38\u5e38\u56e0\u4e3a\u8fd9\u4e2a\u95ee\u9898\u641e\u52301\u70b9\u591a,\u4f46\u90a3\u4f1a\u7f81\u7eca\u5c11,\u6000\u7740\u5b66\u4e60\u548c\u5bf9\u4e8b\u513f\u7684\u8ba4\u771f\uff0c\u518d\u52a0\u4e0a\u4e00\u5757\u548c\u7ec4\u5458\u548c\u9886\u5bfc\u6413\u4e00\u987f,\u5e78\u798f\u611f\u6ee1\u6ee1\u3002<\/p>\n

\u5176\u540e\u4e5f\u5e26\u8fc7\u5f88\u591a\u4eba,\u5408\u4f5c\u8fc7\u8bb8\u591a\u4eba\u3001\u5f62\u5f62\u8272\u8272\u7684\uff0c\u6162\u6162\u7684\u53d1\u73b0\u8d8a\u5f80\u540e\u5165\u884c\u7684\u5f88\u591a\u4eba\u5bb3\u6015\u73af\u5883\u90e8\u7f72\uff0c\u5bb3\u6015\u51fa\u95ee\u9898,\u6240\u4ee5\u62d2\u7edd\u53bb\u5c1d\u8bd5\u90e8\u7f72\u3002\u52a8\u8f84\u5c31\u662f \"\u798f\u62a5\" \u548c \"PUA\" \u9632\u8eab,\u975e\u662f\u7ad9\u5728\u9053\u5fb7\u5236\u9ad8\u70b9\u53bb\u6307\u6458\uff0c\u5f88\u591a\u4e8b\u60c5\u8fc7\u72b9\u4e0d\u53ca\uff0c\u76f2\u76ee\u7684\u968f\u5927\u6d41\u53bb\u6307\u6458\uff0c\u4eba\u751f\u6d3b\u548c\u5de5\u4f5c\u90fd\u662f\u5728\u4e3a\u81ea\u5df1\u8d1f\u8d23\uff0c\u5c3d\u6700\u5927\u7684\u52aa\u529b\uff0c\u505a\u6700\u597d\u7684\u81ea\u5df1\u3001\u83ab\u4f5c\u201c\u603b\u6709\u5201\u6c11\u60f3\u8981\u5bb3\u6715\u201d\u7684\u5fc3\u6001\u592a\u4e45,\u5b9e\u5728\u4e0d\u884c\uff0c\u6362\u4e2a\u73af\u5883\u89e3\u653e\u5c40\u9650\u6027\u3002<\/p>\n

linux\u73af\u5883\u4e4b\u524d\u4e00\u76f4\u6d45\u7528,\u4e4b\u540e\u7b97\u662f\u6709\u8f83\u591a\u7684\u6d89\u8db3,\u6c89\u6dc0\u4e0b\u6765\u7684\u76f8\u5173\u5185\u5bb9\u4e5f\u4f1a\u7ecf\u5e38\u53bb\u5b8c\u5584\u8865\u5145\uff0c\u90e8\u7f72\u53c2\u8003,\u5de5\u4f5c\u4e45\u4e86\u5f88\u591a\u5bf9\u81ea\u8eab\u6765\u8bf4\u56f0\u96be\u7684\u4e8b\u60c5,\u662f\u6ca1\u529e\u6cd5\u7ed5\u8fc7\u53bb\u6216\u8005\u9000\u7f29\u7684\uff0c\u4e00\u5f80\u65e0\u524d\u5427\u3001\u6c38\u8fdc\u7684\u5c11\u5e74<\/p>\n","protected":false},"excerpt":{"rendered":"

\u73b0\u5728\u670d\u52a1\u5668\u8d44\u4ea7\u591a\u79cd\u591a\u6837,\u4e60\u60ef\u4e86\u963f\u91cc\u4e91\u7684\u4fdd\u59c6\u5f0f\u914d\u7f6e,\u5176\u4ed6\u79c1\u6709\u4e91\u7684\u88c5\u673a\u914d\u7f6e\u5404\u6709\u5404\u7684\u98ce\u683c,\u4eca\u5929\u804a\u804anginx\u7a81\u53d1\u72b6\u51b5 […]<\/p>\n","protected":false},"author":1479,"featured_media":200669,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-253901","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/253901","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1479"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=253901"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/253901\/revisions"}],"predecessor-version":[{"id":253905,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/253901\/revisions\/253905"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/200669"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=253901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=253901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=253901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}