{"id":4424,"date":"2025-07-03T02:28:04","date_gmt":"2025-07-02T17:28:04","guid":{"rendered":"https:\/\/eternalsphere.net\/echoes\/?p=4424"},"modified":"2026-06-06T09:15:37","modified_gmt":"2026-06-06T00:15:37","slug":"54i3sjp61upsag2","status":"publish","type":"post","link":"https:\/\/eternalsphere.net\/echoes\/index.php\/2025\/07\/03\/54i3sjp61upsag2\/","title":{"rendered":"\u591a\u670d\u52a1 Nginx \u53cd\u5411\u4ee3\u7406\u914d\u7f6e\u4e0e\u7ec6\u8282\u603b\u7ed3"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u5728\u590d\u6742\u7684\u591a\u670d\u52a1\u670d\u52a1\u5668\u73af\u5883\u4e2d\uff0c\u901a\u8fc7\u5b50\u57df\u540d\u548c Nginx \u53cd\u5411\u4ee3\u7406\u5c06\u4e0d\u540c\u5185\u7f51\u670d\u52a1\u5b89\u5168\u3001\u9ad8\u6548\u5730\u53d1\u5e03\u5230\u516c\u7f51\uff0c\u662f\u4e00\u79cd\u5e38\u89c1\u4e14\u5b9e\u7528\u7684\u67b6\u6784\u65b9\u6848\u3002\u4ee5\u4e0b\u662f\u4e00\u4efd\u8be6\u7ec6\u7684\u914d\u7f6e\u603b\u7ed3\uff0c\u6db5\u76d6\u4e86\u5e38\u7528\u670d\u52a1\uff08\u5982 Nextcloud\u3001Rocket.Chat\u3001WordPress\u3001PVE\u3001PBS\u3001Webmin\u3001Stirling PDF\u3001phpMyAdmin\u3001Portainer\u3001Plex \u7b49\uff09\u5728 Nginx \u4e0a\u7684\u5b9e\u8df5\u914d\u7f6e\u4e0e\u8981\u70b9\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \u6838\u5fc3\u601d\u8def<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6bcf\u4e2a\u670d\u52a1\u4f7f\u7528\u72ec\u7acb\u5b50\u57df\u540d\uff0c\u5982 <code>nextcloud.example.com<\/code>\u3001<code>chat.example.com<\/code> \u7b49<\/li>\n\n\n\n<li>\u6240\u6709 HTTP \u8bf7\u6c42\u7edf\u4e00\u91cd\u5b9a\u5411\u5230 HTTPS<\/li>\n\n\n\n<li>\u524d\u7aef\u7531 Nginx \u7edf\u4e00\u5904\u7406 SSL \u8bc1\u4e66\u3001\u534f\u8bae\u5347\u7ea7\u3001\u8def\u5f84\u8f6c\u53d1\uff0c\u540e\u7aef\u670d\u52a1\u5185\u90e8\u4fdd\u6301\u7b80\u5355<\/li>\n\n\n\n<li>\u901a\u8fc7\u5185\u7f51 IP \u4e0e\u7aef\u53e3\u4e0e\u540e\u7aef\u670d\u52a1\u901a\u4fe1\uff0c\u5b89\u5168\u6027\u66f4\u9ad8<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \u901a\u7528\u914d\u7f6e\u7ed3\u6784<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>server {<br>    listen 80;<br>    server_name example.com;<br>    return 301 https:\/\/$host$request_uri;<br>}<br><br>server {<br>    listen 443 ssl http2;<br>    server_name example.com;<br><br>    client_max_body_size 200M;<br><br>    ssl_certificate \/path\/to\/fullchain.pem;<br>    ssl_certificate_key \/path\/to\/privkey.pem;<br>    ssl_protocols TLSv1.2 TLSv1.3;<br><br>    location \/ {<br>        proxy_pass http:\/\/192.168.x.x:port\/;<br>        proxy_http_version 1.1;<br>        proxy_set_header Upgrade $http_upgrade;<br>        proxy_set_header Connection \"upgrade\";<br>        proxy_set_header Host $http_host;<br><br>        proxy_set_header X-Real-IP $remote_addr;<br>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Forwarded-Proto https;<br>        proxy_set_header X-Nginx-Proxy true;<br><br>        proxy_redirect off;<br>    }<br>}<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \u91cd\u8981\u7ec6\u8282<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83c\udf1f \u5b50\u57df\u540d\u914d\u7f6e<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6bcf\u4e2a\u670d\u52a1\u4f7f\u7528\u72ec\u7acb\u5b50\u57df\uff0cDNS \u6307\u5411\u516c\u7f51 IP<\/li>\n\n\n\n<li>SSL \u8bc1\u4e66\u4e2d\u5305\u542b\u6240\u6709\u5b50\u57df\u540d\uff0c\u96c6\u4e2d\u7ba1\u7406<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83c\udf1f Header \u914d\u7f6e<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Host<\/code> \u5934\u5fc5\u987b\u4f20\u9012\uff0c\u4fdd\u6301\u540e\u7aef\u6b63\u786e\u89e3\u6790\u57df\u540d<\/li>\n\n\n\n<li><code>Upgrade<\/code> \u548c <code>Connection<\/code> \u5934\u7528\u4e8e\u652f\u6301 WebSocket\uff08\u5982 Rocket.Chat\u3001Portainer\u3001Plex \u7b49\uff09<\/li>\n\n\n\n<li><code>X-Forwarded-Proto<\/code> \u8ba9\u540e\u7aef\u611f\u77e5\u662f\u5426\u4e3a HTTPS\uff0c\u907f\u514d\u6df7\u5408\u5185\u5bb9\u8b66\u544a<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83c\udf1f \u5185\u7f51\u5b89\u5168<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u540e\u7aef\u670d\u52a1\u76d1\u542c\u5185\u7f51\u5730\u5740\uff0c\u4e0d\u76f4\u63a5\u66b4\u9732\u516c\u7f51<\/li>\n\n\n\n<li>\u53ef\u4ee5\u914d\u5408\u9632\u706b\u5899\u4ec5\u5141\u8bb8\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u8bbf\u95ee\u5185\u7f51\u7aef\u53e3<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83c\udf1f \u65e5\u5fd7\u914d\u7f6e<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5efa\u8bae\u5bf9\u6bcf\u4e2a\u670d\u52a1\u72ec\u7acb\u8bbe\u7f6e\u8bbf\u95ee\u548c\u9519\u8bef\u65e5\u5fd7\uff0c\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>access_log \/var\/log\/nginx\/service.access.log;<br>error_log  \/var\/log\/nginx\/service.error.log;<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u65b9\u4fbf\u540e\u671f\u8c03\u8bd5\u4e0e\u95ee\u9898\u6392\u67e5\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \u7279\u6b8a\u670d\u52a1\u6ce8\u610f\u4e8b\u9879<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd39 Nextcloud<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u82e5\u540e\u7aef\u914d\u7f6e\u5728\u5b50\u8def\u5f84\uff0c\u5982 <code>\/nextcloud\/<\/code>\uff0c\u9700\u8981\u5728 <code>proxy_pass<\/code> \u5199\u5b8c\u6574\u8def\u5f84\u5e76\u672b\u5c3e\u52a0 <code>\/<\/code><\/li>\n\n\n\n<li>\u4fee\u6539 <code>config.php<\/code> \u4e2d <code>overwrite.cli.url<\/code>\uff0c\u4fdd\u6301\u4e0e\u5b50\u57df\u5bf9\u5e94<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd39 phpMyAdmin<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5efa\u8bae\u914d\u7f6e\u989d\u5916\u7684\u8bbf\u95ee\u9650\u5236\uff08IP \u767d\u540d\u5355\u6216 HTTP Basic Auth\uff09\uff0c\u907f\u514d\u66b4\u9732\u6570\u636e\u5e93\u7ba1\u7406\u9762\u677f<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd39 Portainer\u3001Webmin\u3001Plex \u7b49\u7ba1\u7406\u9762\u677f<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9762\u5411\u516c\u7f51\u65f6\u5efa\u8bae\u5f00\u542f\u66f4\u4e25\u683c\u7684\u8bbf\u95ee\u63a7\u5236\u63aa\u65bd\uff08\u5982 VPN\u3001IP \u9650\u5236\uff09<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \u603b\u7ed3<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7 Nginx \u7ed3\u5408\u5b50\u57df\u540d\u548c\u53cd\u5411\u4ee3\u7406\u67b6\u6784\uff0c\u53ef\u4ee5\u8f7b\u677e\u3001\u5b89\u5168\u5730\u7ba1\u7406\u591a\u5957\u670d\u52a1\uff0c\u7edf\u4e00\u8bc1\u4e66\u914d\u7f6e\uff0c\u7b80\u5316\u540e\u7aef\u8d1f\u8f7d\u3002\u7ec6\u81f4\u5730\u914d\u7f6e header\u3001\u65e5\u5fd7\u548c\u8def\u5f84\u8f6c\u53d1\uff0c\u662f\u4fdd\u8bc1\u670d\u52a1\u7a33\u5b9a\u7684\u91cd\u8981\u57fa\u7840\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udcac \u7ed3\u8bed<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4efd\u914d\u7f6e\u603b\u7ed3\uff0c\u8bb0\u5f55\u4e86\u5178\u578b\u591a\u670d\u52a1\u573a\u666f\u4e0b\u7684\u5b8c\u6574\u5b9e\u8df5\u65b9\u6848\uff0c\u53ef\u4f5c\u4e3a\u4ee5\u540e\u65b0\u914d\u7f6e\u6216\u8fc1\u79fb\u65f6\u7684\u53c2\u8003\u6a21\u677f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u590d\u6742\u7684\u591a\u670d\u52a1\u670d\u52a1\u5668\u73af\u5883\u4e2d\uff0c\u901a\u8fc7\u5b50\u57df\u540d\u548c Nginx \u53cd\u5411\u4ee3\u7406\u5c06\u4e0d\u540c\u5185\u7f51\u670d\u52a1\u5b89\u5168\u3001\u9ad8\u6548\u5730\u53d1\u5e03\u5230\u516c\u7f51\uff0c\u662f\u4e00\u79cd\u5e38\u89c1\u4e14\u5b9e\u7528\u7684\u67b6\u6784\u65b9\u6848\u3002\u4ee5\u4e0b\u662f\u4e00\u4efd\u8be6\u7ec6\u7684\u914d\u7f6e\u603b\u7ed3\uff0c\u6db5\u76d6\u4e86\u5e38\u7528\u670d\u52a1\uff08\u5982 Nextcloud\u3001Rocket.Chat\u3001WordPress\u3001PVE\u3001PBS\u3001Webmin\u3001Stirling PDF\u3001phpMyAdmin\u3001Portainer\u3001Plex \u7b49\uff09\u5728 Nginx \u4e0a\u7684\u5b9e\u8df5\u914d\u7f6e\u4e0e\u8981\u70b9\u3002 \u2705 \u6838\u5fc3\u601d\u8def \u2705 \u901a\u7528\u914d\u7f6e\u7ed3\u6784 server { listen 80; server_name example.com; return 301 https:\/\/$host$request_uri;}server { listen 443 ssl http2; server_name example.com; client_max_body_size 200M; ssl_certificate \/path\/to\/fullchain.pem; ssl_certificate_key \/path\/to\/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; location \/ { proxy_pass http:\/\/192.168.x.x:port\/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection &#8220;upgrade&#8221;; &hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[],"class_list":["post-4424","post","type-post","status-publish","format-standard","hentry","category-rghcu4xwtxm7gjr"],"_links":{"self":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/4424","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/comments?post=4424"}],"version-history":[{"count":2,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/4424\/revisions"}],"predecessor-version":[{"id":4456,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/4424\/revisions\/4456"}],"wp:attachment":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/media?parent=4424"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/categories?post=4424"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/tags?post=4424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}