{"id":7753,"date":"2025-05-19T14:16:50","date_gmt":"2025-05-19T06:16:50","guid":{"rendered":"https:\/\/jerry.lifenet.com.tw\/?p=7753"},"modified":"2025-08-08T11:32:15","modified_gmt":"2025-08-08T03:32:15","slug":"dify-%e5%ae%89%e8%a3%9d","status":"publish","type":"post","link":"https:\/\/jerry.lifenet.com.tw\/?p=7753","title":{"rendered":"Dify \u5b89\u88dd"},"content":{"rendered":"\n<p><a href=\"https:\/\/ithelp.ithome.com.tw\/articles\/10360064\">https:\/\/ithelp.ithome.com.tw\/articles\/10360064<\/a><\/p>\n\n\n\n<p>git clone https:\/\/github.com\/langgenius\/dify.git<br><br>\u5148\u5230&nbsp;<a href=\"https:\/\/www.docker.com\/\">Docker \u7684\u5b98\u7db2<\/a>\u88dd\u597d docker\uff0c\u5c07 Dify \u8907\u88fd\u5230\u4f60\u7684\u88dd\u7f6e\u4e2d<\/p>\n\n\n\n<p>\u5c07 dify \u8907\u88fd\u5230\u4f60\u7684\u4efb\u4f55\u76ee\u9304\u5e95\u4e0b<code>git clone https:\/\/github.com\/langgenius\/dify.git<\/code><\/p>\n\n\n\n<p>\u9032\u5230&nbsp;<code>dify\/docker<\/code>&nbsp;\u4e2d\uff0c\u9019\u908a\u653e\u4e86\u6240\u6709\u548c docker \u6709\u95dc\u7684\u8a2d\u5b9a<br><code>cd dify\/docker<\/code><\/p>\n\n\n\n<p>\u5275\u5efa\u74b0\u5883\u6a94\u6848 (<code>.env<\/code>) \u9019\u908a\u76f4\u63a5\u8907\u88fd\u4ed6\u7684\u7bc4\u4f8b\u5373\u53ef<br><code>cp .env.example .env <\/code><br>\u9019\u908a Dify \u6709 nginx \u7684 container\uff0c\u6703\u5c07\u670d\u52d9\u958b\u5728\u6211\u5011\u96fb\u8166\u7684 80 port \u548c 443 port (\u5982\u679c\u6709\u555f\u52d5 https)\uff0c\u5982\u679c\u4f60\u4e0d\u60f3\u958b\u5728\u9019\u4e9b port \u6216\u8005\u96fb\u8166\u9019\u4e9b port \u5df2\u7d93\u88ab\u4f7f\u7528\u4e86\u53ef\u4ee5\u81ea\u884c\u4fee\u6539&nbsp;<code>.env<\/code><br><code># HTTP port NGINX_PORT=80 <\/code><br><code># \u9019\u908a\u6539\u6210\u4f60\u60f3\u8981\u7684 port <\/code><br><code># ------------------------------ <\/code><br><code># Docker Compose Service Expose Host Port Configurations <\/code><br><code># ------------------------------ <\/code><br><code>EXPOSE_NGINX_PORT=80 <\/code><br><code># \u9019\u908a\u4e5f\u8981\u6539<\/code><\/p>\n\n\n\n<p>\u555f\u52d5 docker compose<br><code>docker compose --project-name dify up -d <em>#  \u9019\u908a\u7684 -d \u662f\u80cc\u666f\u57f7\u884c\u7684\u610f\u601d<\/em><\/code> -p \u547d\u540d DockerName<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong><code>NGINX<\/code> SSL \u8a2d\u5b9a<\/strong><br>.evn \u7de8\u8f2f<br>APP_URL=https:\/\/ai.example.com<br>API_HOST=https:\/\/ai.example.com<br>NGINX_SSL_CERT_FILENAME=fullchain.crt<br>NGINX_SSL_CERT_KEY_FILENAME=privkey.key<\/p>\n\n\n\n<p>docker-compose.yml \u7de8\u8f2f<br>volumes:<br>\/etc\/letsencrypt.sh\/certs\/tahsda.org.tw\/privkey.key:\/etc\/ssl\/privkey.key:ro<br>\/etc\/letsencrypt.sh\/certs\/tahsda.org.tw\/fullchain.crt:\/etc\/ssl\/fullchain.crt:ro<\/p>\n\n\n\n<p><br><br><bdo dir=\"ltr\" lang=\"\"><strong><em><mark style=\"background-color:rgba(0, 0, 0, 0);color:#f90101\" class=\"has-inline-color\">\u6ce8\u610f<\/mark><\/em><\/strong><\/bdo> \u65b0\u589e\u591a\u500b Dify \u9700\u8981\u8a2d\u5b9a DockerName <br>docker compose<br><code>docker compose <code>--project-name<\/code> dockername up -d<\/code><br><br>5003 port \u4e5f\u9700\u8981\u4fee\u6539<br>PLUGIN_DEBUGGING_PORT=5003<br>EXPOSE_PLUGIN_DEBUGGING_PORT=5003<\/p>\n\n\n\n<p>\/etc\/letsencrypt.sh\/certs\/tahsda.org.tw\/fullchain.crt:\/etc\/ssl\/fullchain.crt:ro<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-green-color\"><code>\u4e0d\u4f7f\u7528 NGINX<\/code> \u4e26\u4f7f\u7528 Apache proxy \u81f3 Dify<\/mark><\/strong><br>\u555f\u7528 Apache \u53cd\u5411\u4ee3\u7406\u6a21\u7d44<br>sudo a2enmod proxy proxy_http proxy_wstunnel headers rewrite<br>sudo systemctl restart apache2<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u5728 <code>docker-compose.yaml<\/code> \u628a <code>nginx:<\/code> \u5340\u584a\u8a3b\u89e3\u3002<\/h1>\n\n\n\n<p>\u6216\u4fdd\u7559\uff0c\u4f46\u6539 <code>EXPOSE_NGINX_PORT<\/code>\u3001<code>EXPOSE_NGINX_SSL_PORT<\/code> \u81f3\u9ad8\u4f4d\u57e0\uff0cApache \u53cd\u4ee3\u5230\u8a72\u57e0\u3002<\/p>\n\n\n\n<p>services:<br>web:<br>ports:<br>&#8211; &#8220;3000:3000&#8221;<br>api:<br>ports:<br>&#8211; &#8220;5001:5001&#8221;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><br>\/etc\/apache2\/sites-available\/dify-ssl.conf<\/p>\n\n\n\n<p>&lt;VirtualHost *:8443&gt;<br>ServerName xxxx.com.tw<br>SSLEngine on<br>SSLCertificateFile \/etc\/letsencrypt\/live\/xxxxx.com.tw\/fullchain.pem<br>SSLCertificateKeyFile \/etc\/letsencrypt\/live\/xxxxx.com.tw\/privkey.pem<br>SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1<br>#Include \/etc\/letsencrypt\/options-ssl-apache.conf<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Web \u524d\u7aef\uff08React\uff0c\u542b websocket\uff09\nProxyPreserveHost On\nRequestHeader set X-Forwarded-Proto \"https\"\n# (1) Dify API\uff1a\u5fc5\u9808\u5beb\u5728\u6700\u524d\u9762\uff0c\u907f\u514d\u88ab\u6839\u8def\u5f91\u84cb\u6389\nProxyPass        \/console\/api\/ http:\/\/127.0.0.1:5001\/console\/api\/ retry=0\nProxyPassReverse \/console\/api\/ http:\/\/127.0.0.1:5001\/console\/api\/\n\n# (2) Dify Web Frontend (React\uff0c\u9810\u8a2d 3000)\nProxyPass \/ http:\/\/127.0.0.1:3000\/\nProxyPassReverse \/ http:\/\/127.0.0.1:3000\/\nProxyPass \/socket.io\/ http:\/\/127.0.0.1:3000\/socket.io\/ retry=0\nProxyPassReverse \/socket.io\/ http:\/\/127.0.0.1:3000\/socket.io\/\n\n\n\n# \u53ef\u9078\uff1a\u5f37\u5236\u5c07 http \u8f49 https\nRewriteEngine On\nRewriteCond %{HTTPS} off\nRewriteRule ^ https:\/\/%{HTTP_HOST}%{REQUEST_URI} &#91;L,R=301]\n\nErrorLog  ${APACHE_LOG_DIR}\/dify_ssl_error.log\nCustomLog ${APACHE_LOG_DIR}\/dify_ssl_access.log combined\n&lt;\/VirtualHost&gt;\n\n\u202f\u555f\u7528\u7ad9\u9ede\u4e26\u91cd\u8f09\nsudo a2ensite dify-ssl.conf\nsudo systemctl reload apache2<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/ithelp.ithome.com.tw\/articles\/10360064 git clon &hellip; <a href=\"https:\/\/jerry.lifenet.com.tw\/?p=7753\" class=\"more-link\">\u95b1\u8b80\u5168\u6587 <span class=\"screen-reader-text\">Dify \u5b89\u88dd<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,77],"tags":[],"class_list":["post-7753","post","type-post","status-publish","format-standard","hentry","category-ai","category-dify"],"_links":{"self":[{"href":"https:\/\/jerry.lifenet.com.tw\/index.php?rest_route=\/wp\/v2\/posts\/7753","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jerry.lifenet.com.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jerry.lifenet.com.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jerry.lifenet.com.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jerry.lifenet.com.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7753"}],"version-history":[{"count":17,"href":"https:\/\/jerry.lifenet.com.tw\/index.php?rest_route=\/wp\/v2\/posts\/7753\/revisions"}],"predecessor-version":[{"id":7801,"href":"https:\/\/jerry.lifenet.com.tw\/index.php?rest_route=\/wp\/v2\/posts\/7753\/revisions\/7801"}],"wp:attachment":[{"href":"https:\/\/jerry.lifenet.com.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jerry.lifenet.com.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7753"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jerry.lifenet.com.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}