{"id":283,"date":"2024-09-06T15:37:45","date_gmt":"2024-09-06T07:37:45","guid":{"rendered":"https:\/\/blog.king011.com\/?p=283"},"modified":"2024-09-06T16:12:46","modified_gmt":"2024-09-06T08:12:46","slug":"07-%e5%89%b5%e5%bb%ba%e6%aa%94%e6%a1%88%e5%90%8c%e6%ad%a5","status":"publish","type":"post","link":"https:\/\/blog.king011.com\/?p=283","title":{"rendered":"07-\u5275\u5efa\u6a94\u6848\u540c\u6b65"},"content":{"rendered":"\n<p>syncthing \u662f\u4e00\u500b\u958b\u6e90\u6a94\u6848\u540c\u6b65\u7cfb\u7d71\uff0c\u4f60\u53ef\u4ee5\u5728\u670d\u52d9\u5668\u4e0a\u90e8\u7f72\u4e00\u500b\u670d\u52d9\uff0c\u4e4b\u5f8c\u5728\u5bb6\u548c\u516c\u53f8\u90e8\u7f72\u4e00\u500b\u7bc0\u9ede\uff0c\u9019\u6a23\u9019\u4e09\u500b\u5730\u65b9\u7684\u6a94\u6848\u53ef\u4ee5\u81ea\u52d5\u540c\u6b65\uff0c\u9019\u6bd4\u6536\u8cbb\u7684 Dropbox \u65b9\u6848\u5f37\u4e86\u4e0d\u6b62\u4e00\u9ede(syncthing \u514d\u8cbb\uff0c\u4e26\u4e14\u5bb9\u91cf\u53d6\u6c7a\u8207\u4f60\u670d\u52d9\u5668\u7684\u78c1\u76e4\u5927\u5c0f)\u3002<a href=\"https:\/\/book.king011.com\/view\/zh-Hant\/view\/server-syncthing\/0\">\u9019\u88cf<\/a>\u6709\u672c\u55b5\u5beb\u7684\u7c21\u4ecb\uff0c\u66f4\u591a\u7d30\u7bc0\u5efa\u8b70\u67e5\u770b<a href=\"https:\/\/syncthing.net\/\">\u5b98\u65b9\u6587\u6a94<\/a>\u3002<\/p>\n\n\n\n<p>\u8981\u4f7f\u7528 compose \u90e8\u7f72\u8acb\u53c3\u8003\u5982\u4e0b\u8a2d\u5b9a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>networks:\n  ingress_intranet:\n    external: true\nservices:\n  ingress:\n    image: ${IMAGE_OF_NGINX}\n    restart: always\n    volumes:\n      - .\/conf\/nginx\/nginx.conf:\/etc\/nginx\/nginx.conf:ro\n      - .\/conf\/nginx\/snippets:\/etc\/nginx\/snippets:ro\n      - .\/conf\/nginx\/conf.d:\/etc\/nginx\/conf.d:ro\n    networks:\n      default:\n      ingress_intranet:\n        ipv4_address: ${IP_OF_INGRESS}\n  sync:\n    image: ${IMAGE_OF_SYNC}\n    restart: always\n    ports:\n      - \"22000:22000\/tcp\"\n      - \"22000:22000\/udp\"\n    environment:\n      - PUID=1000\n      - PGID=1000\n      - TZ=Asia\/Shanghai\n    volumes:\n      - \/home\/king\/Sync:\/var\/syncthing\/Sync\n      - \/opt\/data\/sync\/sync:\/var\/syncthing\/config\n  stdiscosrv:\n    build: .\/conf\/stdiscosrv\n    restart: always\n    environment:\n      - PUID=1000\n      - PGID=1000\n      - TZ=Asia\/Shanghai<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">sync<\/h1>\n\n\n\n<p>service sync \u662f\u5fc5\u9808\u7684\uff0c\u5b83\u9ed8\u8a8d\u5728 8384 \u7aef\u53e3\u4e0a\u5553\u52d5\u4e86\u7db2\u9801 ui\uff0c\u5728 22000 \u7aef\u53e3\u4e0a\u958b\u653e\u4e86\u6578\u64da\u540c\u6b65<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">stdiscosrv<\/h1>\n\n\n\n<p>stdiscosrv \u662f\u975e\u5fc5\u9808\u7684\uff0c\u5b83\u81ea\u5efa\u4e86\u4e00\u500b\u767c\u73fe\u670d\u52d9\u5668\uff0c\u4f60\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 sync \u5b98\u65b9\u9ed8\u8a8d\u63d0\u4f9b\u7684\u767c\u73fe\u670d\u52d9\u5668\uff0c\u4f46\u5b98\u65b9\u514d\u8cbb\u7684\u670d\u52d9\u80af\u5b9a\u6c92\u6709\u4f60\u81ea\u5df1\u63d0\u4f9b\u7684\u901f\u5ea6\u5feb<\/p>\n\n\n\n<p>\u56e0\u7232\u5b98\u65b9\u6c92\u6709\u7232 stdiscosrv \u63d0\u4f9b image\uff0c\u6240\u4ee5\u9700\u8981\u81ea\u5df1 build<\/p>\n\n\n\n<p>cat conf\/stdiscosrv\/Dockerfile<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FROM ghcr.io\/linuxserver\/baseimage-ubuntu:focal\n\nRUN set -eux; \\\n    apt-get update; \\\n    apt-get install -y --no-install-recommends syncthing-discosrv; \\\n    rm -rf \/var\/lib\/apt\/lists\/*\n\nCOPY root\/ \/\n\nEXPOSE 80\nVOLUME \/data<\/code><\/pre>\n\n\n\n<p>chmod a+x conf\/stdiscosrv\/root\/etc\/cont-init.d\/30-config<\/p>\n\n\n\n<p>cat conf\/stdiscosrv\/root\/etc\/cont-init.d\/30-config<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/with-contenv bash\n\n# permissions\nchown abc:abc \\\n    \/data<\/code><\/pre>\n\n\n\n<p>chmod a+x conf\/stdiscosrv\/root\/etc\/services.d\/stdiscosrv\/run<\/p>\n\n\n\n<p>cat conf\/stdiscosrv\/root\/etc\/services.d\/stdiscosrv\/run<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/with-contenv bash\n\nexec \\\n    s6-setuidgid abc \\\n    \/usr\/bin\/stdiscosrv -http -listen=':80' -db-dir='\/data' -cert='\/data\/cert.pem' -key='\/data\/key.pem'<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">ingress<\/h1>\n\n\n\n<p>ingress \u4e0d\u662f\u5fc5\u9808\u7684\u4f7f\u7528 nginx \u5275\u5efa\u4e86\u53cd\u4ee3\u5c07 stdiscosrv \u548c sync \u63d0\u4f9b\u7684\u7db2\u9801\u670d\u52d9\u53cd\u4ee3\u5230 80 \u7aef\u53e3\u4f9b\u5165\u53e3\u7db2\u95dc\u8a2a\u554f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server{\n    listen 80;\n    server_name sync.xxx.xxx;\n    location \/{\n        include snippets\/proxy-set.conf;\n        proxy_pass http:\/\/sync:8384;\n    }\n}\nserver{\n    listen 80;\n    server_name stdiscosrv.xxx.xxx;\n    location \/{\n        include snippets\/proxy-set.conf;\n        proxy_pass http:\/\/stdiscosrv;\n    }\n}<\/code><\/pre>\n\n\n\n<p>cat snippets\/proxy-set.conf<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>proxy_connect_timeout                   5s;                     \nproxy_send_timeout                      60s;                                  \nproxy_read_timeout                      60s;\n\n# version\nproxy_http_version 1.1;\nproxy_set_header Host $http_host;\n\n# Allow websocket connections\nproxy_set_header Upgrade $http_upgrade;\nproxy_set_header Connection $http_connection;\n\nproxy_set_header X-Real-IP              $remote_addr;                         \n                                                                                                      \nproxy_set_header X-Forwarded-For        $remote_addr;\n\nproxy_set_header X-Forwarded-Host       $http_host;                      \nproxy_set_header X-Forwarded-Port       $server_port;                           \nproxy_set_header X-Forwarded-Proto      $scheme;                                  \nproxy_set_header X-Forwarded-Scheme     $scheme;                  \n                                                                                                      \nproxy_set_header X-Scheme               $scheme;  \n\n# Pass the original X-Forwarded-For\nproxy_set_header X-Original-Forwarded-For $http_x_forwarded_for;\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 docker compose \u642d\u5efa syncthing \u670d\u52d9\u3002\u5be6\u73fe\u6a94\u6848\u5728 \u5bb6 \u516c\u53f8 \u670d\u52d9\u5668 \u9593\u540c\u6b65\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[50,52,51],"tags":[],"class_list":["post-283","post","type-post","status-publish","format-standard","hentry","category-linux","category-52","category-51"],"blocksy_meta":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.king011.com\/index.php?rest_route=\/wp\/v2\/posts\/283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.king011.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.king011.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.king011.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.king011.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=283"}],"version-history":[{"count":3,"href":"https:\/\/blog.king011.com\/index.php?rest_route=\/wp\/v2\/posts\/283\/revisions"}],"predecessor-version":[{"id":286,"href":"https:\/\/blog.king011.com\/index.php?rest_route=\/wp\/v2\/posts\/283\/revisions\/286"}],"wp:attachment":[{"href":"https:\/\/blog.king011.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.king011.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.king011.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}