{"id":1357,"date":"2024-04-02T12:36:40","date_gmt":"2024-04-02T04:36:40","guid":{"rendered":"https:\/\/hkc.nasclub.vip\/?p=1357"},"modified":"2025-02-19T12:07:54","modified_gmt":"2025-02-19T04:07:54","slug":"docker%e5%ae%89%e8%a3%85nginx%e6%94%af%e6%8c%81http%e6%96%87%e4%bb%b6%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%88%96%e8%80%85webdav","status":"publish","type":"post","link":"https:\/\/hkc.nasclub.vip\/?p=1357","title":{"rendered":"docker\u5b89\u88c5nginx\u652f\u6301HTTP\u6587\u4ef6\u670d\u52a1\u5668\u6216\u8005webdav"},"content":{"rendered":"<h1>\u4ec0\u4e48\u662fnginx\uff1f<\/h1>\n<p>Nginx\uff08\u53d1\u97f3\u4e3a\u201cengine-x\u201d\uff09\u662f\u7528\u4e8e HTTP\u3001HTTPS\u3001SMTP\u3001POP3 \u548c IMAP \u534f\u8bae\u7684\u5f00\u6e90\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u4ee5\u53ca\u8d1f\u8f7d\u5747\u8861\u5668\u3001HTTP \u7f13\u5b58\u548c Web \u670d\u52a1\u5668\uff08\u6e90\u670d\u52a1\u5668\uff09\u3002nginx \u9879\u76ee\u4e00\u5f00\u59cb\u5c31\u975e\u5e38\u6ce8\u91cd\u9ad8\u5e76\u53d1\u3001\u9ad8\u6027\u80fd\u548c\u4f4e\u5185\u5b58\u4f7f\u7528\u7387\u3002\u5b83\u4ee5 2 \u6761\u6b3e\u7c7b BSD \u8bb8\u53ef\u8bc1\u6388\u6743\uff0c\u53ef\u5728 Linux\u3001BSD \u53d8\u4f53\u3001Mac OS X\u3001Solaris\u3001AIX\u3001HP-UX \u4ee5\u53ca\u5176\u4ed6 *nix \u7248\u672c\u4e0a\u8fd0\u884c\u3002\u5b83\u8fd8\u5177\u6709\u7528\u4e8e Microsoft Windows \u7684\u6982\u5ff5\u9a8c\u8bc1\u7aef\u53e3\u3002<\/p>\n<h3>\u5728 nginx \u914d\u7f6e\u4e2d\u4f7f\u7528\u73af\u5883\u53d8\u91cf\uff081.19 \u4e2d\u7684\u65b0\u529f\u80fd\uff09<\/h3>\n<p>\u5f00\u7bb1\u5373\u7528\uff0cnginx \u4e0d\u652f\u6301\u5927\u591a\u6570\u914d\u7f6e\u5757\u4e2d\u7684\u73af\u5883\u53d8\u91cf\u3002\u4f46\u662f\u8fd9\u4e2a\u955c\u50cf\u6709\u4e00\u4e2a\u51fd\u6570\uff0c\u5b83\u4f1a\u5728 nginx \u542f\u52a8\u4e4b\u524d\u63d0\u53d6\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u4f7f\u7528 docker-compose.yml \u7684\u793a\u4f8b\uff1a<\/p>\n<pre class=\"io-enlighter-pre\"><code class=\"code\" data-enlighter-language=\"php\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"\" data-enlighter-highlight=\"\">web:\r\n\u00a0\u00a0image:\u00a0nginx\r\n\u00a0\u00a0volumes:\r\n\u00a0\u00a0\u00a0-\u00a0.\/templates:\/etc\/nginx\/templates\r\n\u00a0\u00a0ports:\r\n\u00a0\u00a0\u00a0-\u00a0\"8080:80\"\r\n\u00a0\u00a0environment:\r\n\u00a0\u00a0\u00a0-\u00a0NGINX_HOST=domain.com\r\n\u00a0\u00a0\u00a0-\u00a0NGINX_PORT=80<\/code><\/pre>\n<p>\u8fd9\u4e9b\u662f\u60a8\u53ef\u4ee5\u8bbe\u7f6e\u7684\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u53ca\u5b83\u4eec\u7684\u4f5c\u7528\u3002\uff08\u7f16\u8bd1\u5b89\u88c5nginx\u652f\u6301webdav\u6a21\u5757\u7684\u60c5\u51b5\u4e0b\uff09<\/p>\n<ul class=\" list-paddingleft-2\">\n<li><code>PUID=1000<\/code>\u5177\u6709\u5bf9\u5377\u7684\u8bfb\/\u5199\u8bbf\u95ee\u6743\u9650\u7684\u7528\u6237 ID\u3002Nginx \u5c06\u4f7f\u7528\u76f8\u540c\u7684\u65b9\u6cd5\u6765\u8bfb\u53d6\/\u5199\u5165\u6587\u4ef6\u5939\u3002<code>.\/path\/to\/dir:\/data<\/code><\/li>\n<li><code>PGID=1000<\/code>\u5bf9\u5377\u5177\u6709\u8bfb\/\u5199\u8bbf\u95ee\u6743\u9650\u7684\u7ec4 ID\u3002Nginx \u5c06\u4f7f\u7528\u76f8\u540c\u7684\u65b9\u6cd5\u6765\u8bfb\u53d6\/\u5199\u5165\u6587\u4ef6\u5939\u3002<code>.\/path\/to\/dir:\/data<\/code><\/li>\n<li><code>TZ=Asia\/Shanghai<\/code>\u6307\u5b9a\u5e95\u5c42 GNU\/Linux \u7cfb\u7edf\u7684\u65f6\u533a\u3002<\/li>\n<li><code>WEBDAV_USERNAME=user<\/code>\u8bbe\u7f6e\u5355\u4e2a\u7528\u6237\u540d\u4ee5\u8bbf\u95ee WebDAV\u3002\u5982\u679c\u672a\u8bbe\u7f6e\uff0c\u5219\u5ffd\u7565\uff0c\u5982\u679c\u63d0\u4f9b\uff0c\u5219\u5ffd\u7565\u3002<code>WEBDAV_PASSWORD<\/code><code>\/config\/nginx\/htpasswd<\/code><\/li>\n<li><code>WEBDAV_PASSWORD=password<\/code>\u5c06\u5bc6\u7801\u8bbe\u7f6e\u4e3a\u8bbf\u95ee WebDAV \u7684\u5355\u4e2a\u7528\u6237\u540d\u3002\u5982\u679c\u672a\u8bbe\u7f6e\uff0c\u5219\u5ffd\u7565\uff0c\u5982\u679c\u63d0\u4f9b\uff0c\u5219\u5ffd\u7565\u3002<code>WEBDAV_USERNAME<\/code><code>\/config\/nginx\/htpasswd<\/code><\/li>\n<li><code>SERVER_NAMES=localhost,ineed.coffee<\/code>\u670d\u52a1\u5668\u7684\u4e3b\u673a\u540d\u4ee5\u9017\u53f7\u5206\u9694\u3002<\/li>\n<li><code>TIMEOUTS_S=1200<\/code>\u8868\u793a\u4e3a\u79d2\uff0c\u540c\u65f6\u8bbe\u7f6e\u5404\u79cd nginx \u8d85\u65f6\uff1a\u3001\u3001\u3001\u3002<code>send_timeout<\/code><code>client_body_timeout<\/code><code>keepalive_timeout<\/code><code>lingering_timeout<\/code><\/li>\n<li><code>CLIENT_MAX_BODY_SIZE=120M<\/code>\u5c06\u6587\u4ef6\u4e0a\u4f20\u5927\u5c0f\u9650\u5236\u4e3a\u8868\u793a\u7684\u503c\uff0c\u8be5\u503c\u5fc5\u987b\u4ee5 \uff08egabytes\uff09 \u6216 \uff08igabytes\uff09 \u7ed3\u5c3e\u3002<code>M<\/code><code>G<\/code><\/li>\n<\/ul>\n<p>1\u3001\u4e0b\u8f7d\u955c\u50cf<\/p>\n<p>\u6253\u5f00container\u00a0manager\u2192\u6ce8\u518c\u8868\u2192\u641c\u7d22\u5e76\u4e0b\u8f7d\uff1anginx<\/p>\n<p><img decoding=\"async\" class=\"ue-image\" src=\"https:\/\/nas.swihp.cn:39997\/file\/wordpress\/nginx\/005.png\" \/><\/p>\n<p>2\u3001\u521b\u5efa\u5bb9\u5668<\/p>\n<p>\u6253\u5f00container\u00a0manager\u2192\u6620\u50cf\u2192\u9009\u62e9nginx\u5e76\u8fd0\u884c<\/p>\n<p><img decoding=\"async\" class=\"ue-image\" src=\"https:\/\/nas.swihp.cn:39997\/file\/wordpress\/nginx\/007.png\" \/><\/p>\n<p>\u8bbe\u7f6e\u5916\u90e8\u7aef\u53e3<\/p>\n<p>\u6620\u5c04\u5bb9\u5668\u6587\u4ef6\u5939\uff1a<\/p>\n<p>\/public\u00a0\u00a0\u00a0\u00a0\/data\u00a0\u00a0\u00a0\u00a0#public\u662f\u8981\u5171\u4eab\u7684\u76ee\u5f55\uff0cdata\u662f\u5bb9\u5668\u5185\u8981\u914d\u7f6e\u5171\u4eab\u7684\u76ee\u5f55\uff0c\u540e\u8fb9\u914d\u7f6e\u6587\u4ef6\u4e2d\u9700\u8981\u7528\u5230data\u3002<\/p>\n<p>\u6620\u5c04\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<p>\/docker\/nginx\/conf\/default.conf\u00a0\u00a0\u00a0\u00a0\/etc\/nginx\/conf.d\/default.conf<\/p>\n<p>#docker\/nginx\/conf\/default.conf\u00a0\u00a0\u00a0\u00a0\u662f\u672c\u5730default.conf\u5b58\u653e\u76ee\u5f55<\/p>\n<p>#\/etc\/nginx\/conf.d\/default.conf\u00a0\u00a0\u00a0\u00a0\u662f\u5bb9\u5668\u5185default.conf\u5b58\u653e\u76ee\u5f55<\/p>\n<p>\u53ef\u4ee5\u76f4\u63a5\u4e0b\u8f7d\u6211\u7f16\u8bd1\u7684\u597d\u7684\u76f4\u63a5\u4f7f\u7528\uff0c\u4e5f\u53ef\u81ea\u884c\u7f16\u8bd1\u3002<a href=\"https:\/\/nas.swihp.cn:39997\/file\/wordpress\/nginx\/default.conf\" target=\"_blank\" rel=\"noopener\">default.conf<\/a><\/p>\n<p><img decoding=\"async\" class=\"ue-image\" src=\"https:\/\/nas.swihp.cn:39997\/file\/wordpress\/nginx\/008.png\" \/><\/p>\n<p>\u76f4\u63a5\u70b9\u4e0b\u4e00\u6b65\uff0c\u5b8c\u6210\u914d\u7f6e\u5e76\u542f\u52a8\u5bb9\u5668\u3002<\/p>\n<p>3\u3001\u76f4\u63a5\u8bbf\u95ee192.168.x.x:30080\/share<\/p>\n<p><img decoding=\"async\" class=\"ue-image\" src=\"https:\/\/nas.swihp.cn:39997\/file\/wordpress\/nginx\/006.png\" \/><\/p>\n<p>4\u3001default.conf\u914d\u7f6e\u5185\u5bb9<\/p>\n<pre class=\"io-enlighter-pre\"><code class=\"code\" data-enlighter-language=\"php\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"\" data-enlighter-highlight=\"\">server {\r\n    listen   80;\r\n    server_name  localhost;\r\n\t    \r\n    #access_log  \/var\/log\/nginx\/host.access.log  main;\r\n\r\n    location \/ {\r\n        root   \/usr\/share\/nginx\/html;\r\n        index  index.html index.htm;\r\n    }\r\n\r\n    #error_page  404              \/404.html;\r\n\r\n    # redirect server error pages to the static page \/50x.html\r\n    #\r\n    error_page   500 502 503 504  \/50x.html;\r\n    location = \/50x.html {\r\n        root   \/usr\/share\/nginx\/html;\r\n    }\r\n    location ^~ \/share {\r\n\t\talias \/data\/; # \u6587\u4ef6\u8def\u5f84\r\n\t\tautoindex on; # \u5f00\u542f\u7d22\u5f15\u529f\u80fd\r\n\t\tautoindex_exact_size off; # \u5173\u95ed\u8ba1\u7b97\u6587\u4ef6\u786e\u5207\u5927\u5c0f\uff08\u5355\u4f4dbytes\uff09\uff0c\u53ea\u663e\u793a\u5927\u6982\u5927\u5c0f\uff08\u5355\u4f4dkb\u3001mb\u3001gb\uff09\r\n\t\tautoindex_localtime on; # \u663e\u793a\u672c\u673a\u65f6\u95f4\u800c\u975e GMT \u65f6\u95f4\r\n\t\tcharset utf-8; #\u907f\u514d\u4e2d\u6587\u4e71\u7801\r\n\t\t}\r\n    # proxy the PHP scripts to Apache listening on 127.0.0.1:80\r\n    #\r\n    #location ~ \\.php$ {\r\n    #    proxy_pass   http:\/\/127.0.0.1;\r\n    #}\r\n\r\n    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:8000\r\n    #\r\n    #location ~ \\.php$ {\r\n    #    root           html;\r\n    #    fastcgi_pass   127.0.0.1:8000;\r\n    #    fastcgi_index  index.php;\r\n    #    fastcgi_param  SCRIPT_FILENAME  \/scripts$fastcgi_script_name;\r\n    #    include        fastcgi_params;\r\n    #}\r\n\r\n    # deny access to .htaccess files, if Apache's document root\r\n    # concurs with nginx's one\r\n    #\r\n    #location ~ \/\\.ht {\r\n    #    deny  all;\r\n    #}\r\n}<\/code><\/pre>\n<p>5\u3001nginx\u914d\u7f6eHTTP\u6587\u4ef6\u670d\u52a1\u5668\u9700\u8981\u6dfb\u52a0\u7684\u53c2\u6570<\/p>\n<p><strong>\u8bbe\u7f6e\u9700\u8981\u5171\u4eab\u7684\u4fe1\u606f<\/strong><\/p>\n<pre class=\"io-enlighter-pre\"><code class=\"code\" data-enlighter-language=\"php\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"\" data-enlighter-highlight=\"\">server {\r\n    listen 80;\r\n    server_name  localhost;  \r\n \r\n    # \u4e0b\u8f7d\r\n    location \/share {                         # share\u4e3a\u57df\u540d\u540e\u8def\u5f84(\u4f8b\uff1axxx.com\/share)\r\n        charset utf-8;                        # \u907f\u514d\u4e2d\u6587\u4e71\u7801\r\n        root    \/home\/downloads;              # \u6587\u4ef6\u5b58\u653e\u76ee\u5f55(root \u9002\u5408\u7b80\u5355\u8def\u5f84\u62fc\u63a5;alias\u7528\u4e8e\u8def\u5f84\u66ff\u6362)\r\n        autoindex on;                         # \u542f\u7528\u81ea\u52a8\u9996\u9875\u529f\u80fd        \r\n        autoindex_exact_size off;             # \u5173\u95ed\u8ba1\u7b97\u6587\u4ef6\u786e\u5207\u5927\u5c0f\uff08\u5355\u4f4dbytes\uff09\uff0c\u53ea\u663e\u793a\u5927\u6982\u5927\u5c0f\uff08\u5355\u4f4dkb\u3001mb\u3001gb\uff09\r\n        autoindex_localtime on;               # \u663e\u793a\u672c\u673a\u65f6\u95f4\u800c\u975e GMT \u65f6\u95f4\r\n \r\n        default_type application\/octet-stream;# \u5c06\u5f53\u524d\u76ee\u5f55\u4e2d\u6240\u6709\u6587\u4ef6\u7684\u9ed8\u8ba4MIME\u7c7b\u578b\u8bbe\u7f6e\u4e3a\r\n                                              # application\/octet-stream\r\n \r\n        if ($request_filename ~* ^.*?\\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){\r\n            # \u5f53\u6587\u4ef6\u683c\u5f0f\u4e3a\u4e0a\u8ff0\u683c\u5f0f\u65f6\uff0c\u5c06\u5934\u5b57\u6bb5\u5c5e\u6027Content-Disposition\u7684\u503c\u8bbe\u7f6e\u4e3a\"attachment\"\r\n            add_header Content-Disposition: 'attachment;'; \r\n        }\r\n        autoindex_format html;                # \u9996\u9875\u683c\u5f0f\u4e3aHTML\r\n        sendfile on;                          # \u5f00\u542f\u96f6\u590d\u5236\u6587\u4ef6\u4f20\u8f93\u529f\u80fd\r\n        sendfile_max_chunk 1m;                # \u6bcf\u4e2asendfile\u8c03\u7528\u7684\u6700\u5927\u4f20\u8f93\u91cf\u4e3a1MB\r\n        tcp_nopush on;                        # \u542f\u7528\u6700\u5c0f\u4f20\u8f93\u9650\u5236\u529f\u80fd\r\n \r\n#       aio on;                               # \u542f\u7528\u5f02\u6b65\u4f20\u8f93\r\n        directio 5m;                          # \u5f53\u6587\u4ef6\u5927\u4e8e5MB\u65f6\u4ee5\u76f4\u63a5\u8bfb\u53d6\u78c1\u76d8\u7684\u65b9\u5f0f\u8bfb\u53d6\u6587\u4ef6\r\n        directio_alignment 4096;              # \u4e0e\u78c1\u76d8\u7684\u6587\u4ef6\u7cfb\u7edf\u5bf9\u9f50\r\n        output_buffers 4 32k;                 # \u6587\u4ef6\u8f93\u51fa\u7684\u7f13\u51b2\u533a\u5927\u5c0f\u4e3a128KB\r\n \r\n#       limit_rate 1m;                        # \u9650\u5236\u4e0b\u8f7d\u901f\u5ea6\u4e3a1MB\r\n#       limit_rate_after 2m;                  # \u5f53\u5ba2\u6237\u7aef\u4e0b\u8f7d\u901f\u5ea6\u8fbe\u52302MB\u65f6\u8fdb\u5165\u9650\u901f\u6a21\u5f0f\r\n        max_ranges 4096;                      # \u5ba2\u6237\u7aef\u6267\u884c\u8303\u56f4\u8bfb\u53d6\u7684\u6700\u5927\u503c\u662f4096B\r\n        send_timeout 20s;                     # \u5ba2\u6237\u7aef\u5f15\u53d1\u4f20\u8f93\u8d85\u65f6\u65f6\u95f4\u4e3a20s\r\n        postpone_output 2048;                 # \u5f53\u7f13\u51b2\u533a\u7684\u6570\u636e\u8fbe\u52302048B\u65f6\u518d\u5411\u5ba2\u6237\u7aef\u53d1\u9001\r\n        chunked_transfer_encoding on;         # \u542f\u7528\u5206\u5757\u4f20\u8f93\u6807\u8bc6\r\n    }\r\n}<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ec0\u4e48\u662fnginx\uff1f Nginx\uff08&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4,6],"tags":[],"class_list":["post-1357","post","type-post","status-publish","format-standard","hentry","category-hkc","category-linux","category-synology"],"_links":{"self":[{"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=\/wp\/v2\/posts\/1357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1357"}],"version-history":[{"count":4,"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=\/wp\/v2\/posts\/1357\/revisions"}],"predecessor-version":[{"id":1674,"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=\/wp\/v2\/posts\/1357\/revisions\/1674"}],"wp:attachment":[{"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}