{"id":1560,"date":"2025-01-24T10:02:47","date_gmt":"2025-01-24T02:02:47","guid":{"rendered":"https:\/\/blog.ttwow.top\/?p=1560"},"modified":"2026-06-19T17:11:56","modified_gmt":"2026-06-19T09:11:56","slug":"docker%e7%9a%84nginx%e9%85%8d%e7%bd%ae%e8%bf%87%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/blog.ttwow.top\/?p=1560","title":{"rendered":"docker\u7684nginx\u914d\u7f6e\u8fc7\u7a0b"},"content":{"rendered":"<p>\u542f\u52a8<\/p>\n<pre><code class=\"language-shell\">docker run -d --name nginx --privileged -p 8000:8000 -p 8091:8091 \\\n    -v \/docker\/nginx\/html\/ruoyi-ui:\/usr\/share\/nginx\/html\/ruoyi-ui \\\n    -v \/docker\/nginx\/html\/samr-ui:\/usr\/share\/nginx\/html\/samr-ui \\\n    -v \/home\/nginx\/conf\/nginx.conf:\/etc\/nginx\/nginx.conf -v \/home\/nginx\/logs:\/var\/log\/nginx \\\n    nginx<\/code><\/pre>\n<p>nginx.conf<\/p>\n<pre><code class=\"language-shell\">worker_processes 1;\n\nevents {\n    worker_connections 1024;\n}\n\nhttp {\n    include mime.types;\n    default_type application\/octet-stream;\n    client_max_body_size 100M;\n    sendfile on;\n    keepalive_timeout 65;\n\n    server {\n        listen 80;\n        server_name localhost;\n        charset utf-8;\n\n        location \/ {\n            root \/usr\/share\/nginx\/html\/ruoyi-ui;\n            try_files $uri $uri\/ \/index.html;\n            index index.html index.htm;\n        }\n\n        location \/prod-api\/ {\n            proxy_set_header Host $http_host;\n            proxy_set_header X-Real-IP $remote_addr;\n            proxy_set_header REMOTE-HOST $remote_addr;\n            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n            proxy_pass http:\/\/172.16.82.75:8080\/;\n        }\n\n        error_page 500 502 503 504 \/50x.html;\n        location = \/50x.html {\n            root html;\n        }\n    }\n\n    server {\n        listen 8091;\n        server_name localhost;\n        charset utf-8;\n\n        location \/samr {\n            root \/usr\/share\/nginx\/html\/samr-ui;\n            try_files $uri $uri\/ @router;\n            index index.html index.htm;\n        }\n\n        root \/usr\/share\/nginx\/html\/samr-ui;\n\n        location \/ {\n            #\u6307\u5411\u4e0b\u9762\u7684@router\u5426\u5219\u4f1a\u51fa\u73b0vue\u8def\u7531\u5728nginx\u4e2d\u5237\u65b0\u51fa\u73b0404\n            try_files $uri $uri\/ @router;\n            index index.html;\n        }\n\n        #\u5bf9\u5e94\u4e0a\u9762\u7684@router\uff0c\u4e3b\u8981\u539f\u56e0\u662f\u8def\u7531\u7684\u8def\u5f84\u8d44\u6e90\u5e76\u4e0d\u662f\u4e00\u4e2a\u771f\u5b9e\u7684\u8def\u5f84\uff0c\u6240\u4ee5\u65e0\u6cd5\u627e\u5230\u5177\u4f53\u7684\u6587\u4ef6\n        #\u56e0\u6b64\u9700\u8981rewrite\u5230index.html\u4e2d\uff0c\u7136\u540e\u4ea4\u7ed9\u8def\u7531\u5728\u5904\u7406\u8bf7\u6c42\u8d44\u6e90\n        location @router {\n            rewrite ^.*$ \/index.html last;\n        }\n\n        #error_page  404              \/404.html;\n\n        # (\u5fc5\u987b)\u4e3acss\u548cjs\u6587\u4ef6\u7684\u8bf7\u6c42\u6dfb\u52a0\u8bf7\u6c42\u5934\uff0c\u9632\u6b62\u51fa\u73b0response\u7684contentType\u4e3atext\/html\uff0c\u6d4f\u89c8\u5668\u6309\u7167html\u89e3\u6790\u7136\u540e\u62a5\u9519\n        location ~ \\.css {\n            add_header Content-Type text\/css;\n        }\n        location ~ \\.js {\n            add_header Content-Type application\/x-javascript;\n        }\n        # (\u5fc5\u987b)\u8bbe\u7f6ehtml\u4e0d\u8fdb\u884c\u7f13\u5b58\n        location ~ \\.html {\n            add_header Cache-Control no-cache;\n        }\n\n        error_page 500 502 503 504 \/50x.html;\n        location = \/50x.html {\n            root html;\n        }\n    }\n}\n<\/code><\/pre>\n<p>\u65b0\u95ee\u9898<\/p>\n<pre><code class=\"language-shell\">docker run -d --name nginx --privileged -p 80:80 -p 8000:8000 -p 8091:8091 -p 8095:8095 \\\n    -v \/docker\/nginx\/html\/ruoyi-ui:\/usr\/share\/nginx\/html\/ruoyi-ui \\\n    -v \/docker\/nginx\/html\/samr-ui:\/usr\/share\/nginx\/html\/samr-ui \\\n    -v \/docker\/nginx\/html\/quality-ui:\/usr\/share\/nginx\/html\/quality-ui \\\n    -v \/home\/nginx\/conf\/nginx.conf:\/etc\/nginx\/nginx.conf -v \/home\/nginx\/logs:\/var\/log\/nginx \\\n    nginx\n<\/code><\/pre>\n<pre><code class=\"language-shell\">worker_processes 1;\n\nevents {\n    worker_connections 1024;\n}\n\nhttp {\n    include mime.types;\n    default_type application\/octet-stream;\n    client_max_body_size 100M;\n    sendfile on;\n    keepalive_timeout 65;\n    server {\n        listen 8000;\n        server_name localhost;\n        charset utf-8;\n        location \/ {\n            root \/usr\/share\/nginx\/html\/ruoyi-ui;\n            try_files $uri $uri\/ \/index.html;\n            index index.html index.htm;\n        }\n        location \/prod-api\/ {\n            proxy_set_header Host $http_host;\n            proxy_set_header X-Real-IP $remote_addr;\n            proxy_set_header REMOTE-HOST $remote_addr;\n            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n            proxy_pass http:\/\/172.16.82.75:8080\/;\n        }\n        error_page 500 502 503 504 \/50x.html;\n        location = \/50x.html {\n            root html;\n        }\n    }\n\n    server {\n        listen 8091;\n        server_name localhost;\n        charset utf-8;\n        location \/samr {\n            root \/usr\/share\/nginx\/html\/samr-ui;\n            try_files $uri $uri\/ @router;\n            index index.html index.htm;\n        }\n        root \/usr\/share\/nginx\/html\/samr-ui;\n        location \/ {\n            try_files $uri $uri\/ @router;\n            index index.html;\n        }\n        location @router {\n            rewrite ^.*$ \/index.html last;\n        }\n\n        #error_page  404              \/404.html;\n        location ~ \\.css {\n            add_header Content-Type text\/css;\n        }\n        location ~ \\.js {\n            add_header Content-Type application\/x-javascript;\n        }\n        location ~ \\.html {\n            add_header Cache-Control no-cache;\n        }\n\n        error_page 500 502 503 504 \/50x.html;\n        location = \/50x.html {\n            root html;\n        }\n    }\n\n    server {\n        listen 8095;\n        server_name localhost;\n        charset utf-8;\n        location \/samr {\n            root \/usr\/share\/nginx\/html\/quality-ui;\n            try_files $uri $uri\/ @router;\n            index index.html index.htm;\n        }\n        root \/usr\/share\/nginx\/html\/quality-ui;\n        location \/ {\n            try_files $uri $uri\/ @router;\n            index index.html;\n        }\n        location @router {\n            rewrite ^.*$ \/index.html last;\n        }\n\n        #error_page  404              \/404.html;\n        location ~ \\.css {\n            add_header Content-Type text\/css;\n        }\n        location ~ \\.js {\n            add_header Content-Type application\/x-javascript;\n        }\n        location ~ \\.html {\n            add_header Cache-Control no-cache;\n        }\n\n        error_page 500 502 503 504 \/50x.html;\n        location = \/50x.html {\n            root html;\n        }\n    }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u542f\u52a8 docker run -d &#8211;name nginx &#8211;privileged -p 8000:8000 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[131],"tags":[32,60],"class_list":["post-1560","post","type-post","status-publish","format-standard","hentry","category-docker-ci-cd","tag-docker","tag-nginx"],"_links":{"self":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/1560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1560"}],"version-history":[{"count":4,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/1560\/revisions"}],"predecessor-version":[{"id":1572,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/1560\/revisions\/1572"}],"wp:attachment":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}