{"id":245331,"date":"2022-06-29T09:26:24","date_gmt":"2022-06-29T01:26:24","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=245331"},"modified":"2022-06-19T12:27:13","modified_gmt":"2022-06-19T04:27:13","slug":"nginx-proxy-setting","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/nginx-proxy-setting.html","title":{"rendered":"nginx\u53cd\u5411\u4ee3\u7406\u4ee5\u53ca\u8fc7\u6ee4\u9759\u6001\u6587\u4ef6\u7684\u5e38\u7528\u914d\u7f6e"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nnginx\u6709\u4e24\u4e2a\u91cd\u8981\u7684\u529f\u80fd\uff0c\u4e00\u4e2a\u662f\u9759\u6001\u8d44\u6e90\u670d\u52a1\u5668\uff0c\u53e6\u4e00\u4e2a\u5c31\u662f\u53cd\u5411\u4ee3\u7406\uff0c\u672c\u6587\u4e3b\u8981\u5bf9nginx\u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\u529f\u80fd\u7684\u4e3b\u8981\u914d\u7f6e\u505a\u4e00\u4e2a\u8bb2\u89e3\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/a>
\nnginx\u6709\u4e24\u4e2a\u91cd\u8981\u7684\u529f\u80fd\uff0c\u4e00\u4e2a\u662f\u9759\u6001\u8d44\u6e90\u670d\u52a1\u5668\uff0c\u53e6\u4e00\u4e2a\u5c31\u662f\u53cd\u5411\u4ee3\u7406\uff0c\u672c\u6587\u4e3b\u8981\u5bf9nginx\u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\u529f\u80fd\u7684\u4e3b\u8981\u914d\u7f6e\u505a\u4e00\u4e2a\u8bb2\u89e3\u3002\u4e0b\u9762\u5148\u770b\u4e00\u4e2anginx\u7684\u5b8c\u6574\u914d\u7f6e.<\/p>\n

nginx\u914d\u7f6e<\/strong><\/span><\/div>\n

\u4e00\u4e2anginx\u7684\u5b8c\u6574\u914d\u7f6e\u53ca\u89e3\u91ca<\/p>\n

\r\nuser  www www;\r\nworker_processes auto;\r\nerror_log  \/www\/wwwlogs\/nginx_error.log  crit;\r\npid        \/www\/server\/nginx\/logs\/nginx.pid;\r\nworker_rlimit_nofile 51200;\r\n\r\nevents\r\n    {\r\n        use epoll;\r\n        worker_connections 51200;\r\n        multi_accept on;\r\n    }\r\n\r\nhttp\r\n    {\r\n        include       mime.types;\r\n        #include luawaf.conf;\r\n\r\n        include proxy.conf;\r\n\r\n        default_type  application\/octet-stream;\r\n\r\n        server_names_hash_bucket_size 512;\r\n        client_header_buffer_size 32k;\r\n        large_client_header_buffers 4 32k;\r\n        client_max_body_size 50m;\r\n\r\n        sendfile   on;\r\n        tcp_nopush on;\r\n\r\n        keepalive_timeout 60;\r\n\r\n        tcp_nodelay on;\r\n\r\n        fastcgi_connect_timeout 300;\r\n        fastcgi_send_timeout 300;\r\n        fastcgi_read_timeout 300;\r\n        fastcgi_buffer_size 64k;\r\n        fastcgi_buffers 4 64k;\r\n        fastcgi_busy_buffers_size 128k;\r\n        fastcgi_temp_file_write_size 256k;\r\n        fastcgi_intercept_errors on;\r\n\r\n        gzip on;\r\n        gzip_min_length  1k;\r\n        gzip_buffers     4 16k;\r\n        gzip_http_version 1.1;\r\n        gzip_comp_level 2;\r\n        gzip_types     text\/plain application\/javascript application\/x-javascript text\/javascript text\/css application\/xml;\r\n        gzip_vary on;\r\n        gzip_proxied   expired no-cache no-store private auth;\r\n        gzip_disable   \"MSIE [1-6]\\.\";\r\n\r\n        limit_conn_zone $binary_remote_addr zone=perip:10m;\r\n        limit_conn_zone $server_name zone=perserver:10m;\r\n\r\n        server_tokens off;\r\n        access_log off;\r\n\r\nserver\r\n    {\r\n       listen       80; \r\n       server_name www.bxoon.com;\r\n       location \/ {\r\n            proxy_pass http:\/\/www.bxoon.com:8088\/;\r\n       }\r\n\r\n        location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf|css|js|eot|svg|ttf|woff|woff2|properties|json)$ {\r\n                proxy_pass http:\/\/localhost:8088;\r\n                proxy_read_timeout 600s;\r\n            proxy_set_header ?X-Real-IP ?$remote_addr;\r\n            proxy_set_header Host $host:$server_port;\r\n            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n        }\r\n    }\r\nserver\r\n    {\r\n       listen       80;\r\n       server_name www.43ba.com;\r\n       location \/ {\r\n            proxy_pass http:\/\/www.bxoon.com:8088\/;\r\n       }\r\n    }\r\n}\r\n<\/pre>\n

\u4e3b\u8981\u90e8\u5206\u5728server\u91cc\u9762<\/p>\n

\r\nserver\r\n    {\r\n       listen       80;         #\u76d1\u6d4b\u7684\u7aef\u53e3\u53f7\r\n       server_name www.bxoon.com;   #\u8bbf\u95ee\u7684\u57df\u540d\r\n       location \/ {\r\n            proxy_pass http:\/\/www.bxoon.com:8088\/; #\u8f6c\u53d1\u5230\u54ea\u91cc\u53bb\r\n       }\r\n\r\n        location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf|css|js|eot|svg|ttf|woff|woff2|properties|json)$ {\r\n                proxy_pass http:\/\/localhost:8088;\r\n                proxy_read_timeout 600s;\r\n            proxy_set_header ?X-Real-IP ?$remote_addr;\r\n            proxy_set_header Host $host:$server_port;\r\n            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n        }\r\n    }\r\nserver\r\n    {\r\n       listen       80;\r\n       server_name www.43ba.com;\r\n       location \/ {\r\n            proxy_pass http:\/\/www.bxoon.com:8088\/;\r\n       }\r\n    }\r\n<\/pre>\n

\u8fd9\u91cc\u7684\u610f\u601d\u662f\u8bbf\u95ee www.bxoon.com:80 \u8fd9\u6837\u7684\u5730\u5740\u7684\u8bf7\u6c42\u4f1a\u88ab\u8f6c\u53d1\u5230www.bxoon.com:8088\u91cc\u9762\u53bb\u3002\u5f53\u7136\uff0c\u6211\u4eec\u9700\u8981\u628awww.bxoon.com\u6620\u5c04\u5230nginx\u90e8\u7f72\u7684\u6240\u5728\u670d\u52a1\u5668\u7684IP\uff0c\u8fd9\u6837nginx\u624d\u80fd\u63a5\u6536\u5230\u8bf7\u6c42\u8fdb\u800c\u8fdb\u884c\u8f6c\u53d1\u3002
\nserver\u662f\u53ef\u4ee5\u914d\u7f6e\u591a\u4e2a\u7684\uff0c\u6bd4\u5982\u4e0a\u9762\u7684\u914d\u7f6e\u5c31\u6709\u4e24\u4e2aserver\uff0c\u7b2c\u4e8c\u4e2aserver\u7684\u610f\u601d\u662f\u628a\u8bbf\u95ee www.43ba.com\u7684\u8bf7\u6c42\u89e3\u6790\u5230www.bxoon.com:8088 \u8fd9\u91cc\u53bb\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5bf9\u4e8e\u4e0a\u8ff0\u8bf7\u6c42\uff0c\u65e0\u8bba\u7528\u6237\u8bbf\u95ee\u7684\u662fwww.bxoon.com:80\u8fd8\u662f www.43ba.com\uff0c\u6700\u7ec8\u8bf7\u6c42\u90fd\u4f1a\u88ab\u8f6c\u53d1\u5230www.bxoon.com:8088<\/p>\n

\u5173\u4e8e\u9759\u6001\u8d44\u6e90\u8fc7\u6ee4<\/strong><\/span><\/div>\n

\u6309\u7167\u4e0a\u8bc9\u914d\u7f6e\u914d\u7f6e\u597d\u4e4b\u540e\u4f1a\u53d1\u73b0css\u3001js\u3001\u56fe\u7247\u8fd9\u4e9b\u90fd\u52a0\u8f7d\u4e0d\u51fa\u6765\u4e86\uff0c\u8fd9\u662f\u56e0\u4e3anginx\u9ed8\u8ba4\u662f\u5f00\u542f\u4e86\u9759\u6001\u8d44\u6e90\u8fc7\u6ee4\u7684\uff0c\u8fd9\u662f\u4ec0\u4e48\u610f\u601d\u5462\uff1f\u6587\u7ae0\u5f00\u5934\u8bf4\u8fc7\uff0cnginx\u5904\u4e86\u53ef\u4ee5\u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u5916\u8fd8\u53ef\u4ee5\u4f5c\u4e3a\u9759\u6001\u8d44\u6e90\u670d\u52a1\u5668\uff0c\u6240\u4ee5nginx\u5bf9\u4e8ecss\u3001js\u3001\u56fe\u7247\u8fd9\u4e9b\u9759\u6001\u8d44\u6e90\uff0c\u9ed8\u8ba4\u662f\u5f00\u542f\u4ee3\u7406\u7684\uff0c\u5f53\u6d4f\u89c8\u5668\u8bf7\u6c42\u8fd9\u4e9b\u8d44\u6e90\u7684\u65f6\u5019nginx\u9ed8\u8ba4\u4e0d\u4f1a\u53bb\u6211\u4eec\u7684\u540e\u7aeftomcat\u8bf7\u6c42\u8d44\u6e90\uff0c\u800c\u662f\u4f1a\u5728\u81ea\u5df1\u7684\u76ee\u5f55\u4e0b\u9762\u627e\uff0c\u4f46\u662f\u56e0\u4e3a\u6211\u4eec\u7684\u9879\u76ee\u662f\u653e\u5728tomcat\u91cc\u9762\uff0c\u5f88\u660e\u663e\u8fd9\u91cc\u662f\u627e\u4e0d\u5230\u7684\uff0c\u6240\u4ee5\u5c31\u4f1a\u52a0\u8f7d\u4e0d\u51fa\u6765\uff0c\u90a3\u4e48\u6211\u4eec\u9700\u8981\u914d\u7f6enginx\u4e0d\u5e2e\u6211\u4eec\u4ee3\u7406\u9759\u6001\u8d44\u6e90\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u505a\u5982\u4e0b\u914d\u7f6e<\/p>\n

\r\nlocation ~ .*\\.(gif|jpg|jpeg|png|bmp|swf|css|js|eot|svg|ttf|woff|woff2|properties|json)$ {\r\n            proxy_pass http:\/\/localhost:8088;\r\n            proxy_read_timeout 600s;\r\n      proxy_set_header ?X-Real-IP ?$remote_addr;\r\n      proxy_set_header Host $host:$server_port;\r\n      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n        }\r\n<\/pre>\n

\u8fd9\u662f\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5199\u6cd5\uff0c\u62ec\u53f7\u4e2d\u7684\u4ee3\u8868\u6587\u4ef6\u7684\u7c7b\u578b\uff0c\u914d\u7f6e\u4e86\u8fd9\u4e2a\u4e4b\u540e\uff0c\u5c31\u662f\u8bf4\u8bf7\u6c42\u9759\u6001\u8d44\u6e90\u7684\u65f6\u5019\u4e0d\u4f1a\u53bbnginx\u914d\u7f6e\u7684\u9759\u6001\u8d44\u6e90\u76ee\u5f55\u4e0b\u627e\uff0c\u800c\u4f1a\u76f4\u63a5\u53bb\u539f\u9879\u76ee\u4e2d\u627e\uff0c\u4e5f\u5c31\u662f\u6211\u4eec\u540e\u7aef\u7684tomcat\u4e2d\u627e\u3002<\/p>\n

\u4f7f\u7528Nginx\u8fc7\u7a0b\u4e2d\u7684\u4e00\u4e9b\u62a5\u9519\u5904\u7406\u65b9\u6cd5<\/strong><\/span><\/div>\n

[error] 21#21: *1 open() \u201c\/usr\/share\/nginx\/html\/favicon.ico\u201d failed (2: No such file or directory)
\n\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u914d\u7f6e\u5982\u4e0b<\/p>\n

\r\nlocation = \/favicon.ico {\r\n    log_not_found off;\r\n    access_log off;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

nginx\u6709\u4e24\u4e2a\u91cd\u8981\u7684\u529f\u80fd\uff0c\u4e00\u4e2a\u662f\u9759\u6001\u8d44\u6e90\u670d\u52a1\u5668\uff0c\u53e6\u4e00\u4e2a\u5c31\u662f\u53cd\u5411\u4ee3\u7406\uff0c\u672c\u6587\u4e3b\u8981\u5bf9nginx\u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\u529f\u80fd\u7684\u4e3b […]<\/p>\n","protected":false},"author":643,"featured_media":245337,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-245331","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\/245331","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\/643"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=245331"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/245331\/revisions"}],"predecessor-version":[{"id":245339,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/245331\/revisions\/245339"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/245337"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=245331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=245331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=245331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}