{"id":1723,"date":"2017-11-09T16:22:45","date_gmt":"2017-11-09T08:22:45","guid":{"rendered":"https:\/\/zoco.me\/?p=69"},"modified":"2017-11-09T16:22:45","modified_gmt":"2017-11-09T08:22:45","slug":"nginx-reverse-proxy-config","status":"publish","type":"post","link":"https:\/\/cloudbool.com\/archive\/nginx-reverse-proxy-config.html","title":{"rendered":"Nginx\u53cd\u5411\u4ee3\u7406\u914d\u7f6e"},"content":{"rendered":"<p>\u524d\u51e0\u5929\u8bf4\u4e86\uff0c\u6211\u6709\u4e2a\u7f51\u7ad9\u6570\u636e\u5e93\u5b9e\u5728\u662f\u592a\u5927\u4e86\uff0c\u5bfc\u81f4\u4e00\u822c\u7684VPS\u9ed8\u8ba4\u786c\u76d8\u7a7a\u95f4\u4e0d\u591f\u653e\u7f6e\u90a3\u4e48\u591a\u6570\u636e\uff0c\u4e8e\u662f\u540e\u6765\u6211\u5c31\u627e\u4e86\u53f0\u786c\u76d8\u7a7a\u95f4\u8db3\u591f\u5927\u7684VPS\uff0c\u5728\u4e0a\u9762\u914d\u7f6e\u597dPHP\u3001Nginx\u3001MySQL\uff0c\u4f7f\u5f97\u80fd\u591f\u6b63\u5e38\u8bbf\u95ee\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u7531\u4e8e\u90a3\u53f0\u673a\u5668\u7531\u4e8e\u67d0\u4e9b\u539f\u56e0\u4e0d\u592a\u65b9\u4fbf\u4ece\u56fd\u5185\u8bbf\u95ee\uff0c\u6211\u5c31\u5728\u8003\u8651\u901a\u8fc7\u627e\u4e00\u53f0\u673a\u5668\u8fdb\u884c\u53cd\u5411\u4ee3\u7406\uff0c\u52a0\u5feb\u56fd\u5185\u8bbf\u95ee\u901f\u5ea6\uff0c\u4e8e\u662f\u5c31\u6709\u4e86\u8fd9\u4efd\u914d\u7f6e\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u76f4\u63a5\u4e0a\u914d\u7f6e\u5427\uff0c\u4e5f\u6ca1\u4ec0\u4e48\u597d\u89e3\u91ca\u7684\u3002<\/p>\n<p>\u5f3a\u5236\u901a\u8fc780\u7aef\u53e3\u8df3\u8f6c\u5230443\u7aef\u53e3\u7684HTTPS\uff0c\u5e76\u8bb0\u5f55\u65e5\u5fd7\u3002<\/p>\n<pre><code>server {\n    listen   443 ssl http2; \n    ssl_protocols TLSv1.2 TLSv1.1 TLSv1;\n    ssl_certificate     \/etc\/letsencrypt\/live\/read.xxx.xxx\/fullchain.pem;\n    ssl_certificate_key \/etc\/letsencrypt\/live\/read.xxx.xxx\/privkey.pem; \n\n    server_name read.xxx.xxx;\n\n    access_log \/var\/log\/nginx\/read.log;\n    error_log \/var\/log\/nginx\/read.error.log;\n\n\n    error_page 404 \/404.html;\n\n    error_page 500 502 503 504 \/50x.html;\n    location = \/50x.html {\n        root \/usr\/share\/nginx\/www;\n    }\n\n    location \/ {\n        proxy_pass  http:\/\/11.22.33.44:1111\/;\n        proxy_redirect     off;\n        proxy_set_header   Host             $host;\n        proxy_set_header   X-Real-IP        $remote_addr;\n        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;\n    }\n\n}\n\nserver {\n    listen 80;\n    server_name read.xxx.xxx;\n    location \/ {\n        rewrite ^\/(.*)$ https:\/\/read.xxx.xxx\/$1 permanent;\n    }\n}\n<\/code><\/pre>\n<p>\u66ff\u6362\u76f8\u5173\u53c2\u6570\uff0c\u914d\u7f6e\u597d\u8bc1\u4e66\uff0c\u8fd9\u6837\u5c31\u80fd\u901a\u8fc7\u4ee3\u7406\u673a\u5668\u8fdb\u884c\u52a0\u901f\u8bbf\u95ee\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u51e0\u5929\u8bf4\u4e86\uff0c\u6211\u6709\u4e2a\u7f51\u7ad9\u6570\u636e\u5e93\u5b9e\u5728\u662f\u592a\u5927\u4e86\uff0c\u5bfc\u81f4\u4e00\u822c\u7684VPS\u9ed8\u8ba4\u786c\u76d8\u7a7a\u95f4\u4e0d\u591f\u653e\u7f6e\u90a3\u4e48\u591a\u6570\u636e\uff0c\u4e8e\u662f\u540e\u6765\u6211\u5c31\u627e\u4e86\u53f0\u786c &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/cloudbool.com\/archive\/nginx-reverse-proxy-config.html\"> <span class=\"screen-reader-text\">Nginx\u53cd\u5411\u4ee3\u7406\u914d\u7f6e<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":""},"categories":[8],"tags":[76],"class_list":["post-1723","post","type-post","status-publish","format-standard","hentry","category-tech","tag-nginx"],"_links":{"self":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/posts\/1723","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/comments?post=1723"}],"version-history":[{"count":0,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/posts\/1723\/revisions"}],"wp:attachment":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/media?parent=1723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/categories?post=1723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/tags?post=1723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}