【问题标题】:Minio console not accessible behind nginx reverse proxy在 nginx 反向代理后面无法访问 Minio 控制台
【发布时间】:2022-06-10 17:37:31
【问题描述】:

我正在尝试将 example.com/minio 位置重定向到 minio 控制台,该控制台在 nginx 代理后面运行,均由 docker compose 文件运行。我的问题是,当我尝试将 minio 端点反向代理到路径时,例如 /minio 它不起作用,但是当我在 nginx 反向代理的根路径上运行 minio 反向代理时,它可以工作.我真的无法找出问题所在。

这是我的撰写文件:

services:
  nginx:
    container_name: nginx
    image: nginx
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
      - ./log/nginx:/var/log/nginx/
  minio:
    image: minio/minio
    container_name: minio
    volumes:
      - ./data/minio/:/data
    command: server /data --address ':9000' --console-address ':9001'
    environment:
      MINIO_ROOT_USER: minio_admin
      MINIO_ROOT_PASSWORD: minio_123456
    ports:
      - 9000
      - 9001
    restart: always
    logging:
      driver: "json-file"
      options:
        max-file: "10"
        max-size: 20m
    healthcheck:
      test: ["CMD", "curl", "-f", "http://127.0.0.1:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3

我的nginx配置是这样的:

server {
    listen 80;
    server_name example.com;

    # To allow special characters in headers
    ignore_invalid_headers off;
    # Allow any size file to be uploaded.
    # Set to a value such as 1000m; to restrict file size to a specific value
    client_max_body_size 0;
    # To disable buffering
    proxy_buffering off;


    access_log /var/log/nginx/service-access.log;
    error_log /var/log/nginx/service-error.log debug;

    location / {
        return 200 "salam";
        default_type text/plain;
    }
    location /minio {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;

        proxy_connect_timeout 300;
        # Default is HTTP/1, keepalive is only enabled in HTTP/1.1
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        chunked_transfer_encoding off;

        proxy_pass http://minio:9001;
    }
}

我在域中看到的 minio 控制台的图片是这样的:

以及卷曲端点的响应($ curl -k http://example.com/minio):

<null>
    <html lang="en">
        <head>
            <meta charset="utf-8" />
            <base href="/" />
            <meta content="width=device-width,initial-scale=1" name="viewport" />
            <meta content="#081C42" media="(prefers-color-scheme: light)" name="theme-color" />
            <meta content="#081C42" media="(prefers-color-scheme: dark)" name="theme-color" />
            <meta content="MinIO Console" name="description" />
            <link href="./styles/root-styles.css" rel="stylesheet" />
            <link href="./apple-icon-180x180.png" rel="apple-touch-icon" sizes="180x180" />
            <link href="./favicon-32x32.png" rel="icon" sizes="32x32" type="image/png" />
            <link href="./favicon-96x96.png" rel="icon" sizes="96x96" type="image/png" />
            <link href="./favicon-16x16.png" rel="icon" sizes="16x16" type="image/png" />
            <link href="./manifest.json" rel="manifest" />
            <link color="#3a4e54" href="./safari-pinned-tab.svg" rel="mask-icon" />
            <title>MinIO Console</title>
            <script defer="defer" src="./static/js/main.eec275cb.js"></script>
            <link href="./static/css/main.90d417ae.css" rel="stylesheet">
        </head>
        <body>
            <noscript>You need to enable JavaScript to run this app.</noscript>
            <div id="root">
                <div id="preload">
                    <img src="./images/background.svg" />
                    <img src="./images/background-wave-orig2.svg" />
                </div>
                <div id="loader-block">
                    <img src="./Loader.svg" />
                </div>
            </div>
        </body>
    </html>
    %

【问题讨论】:

    标签: docker nginx docker-compose minio


    【解决方案1】:

    minio 在非默认路径(如位置 /minio)下不起作用

    你需要使用 地点 / { …… proxy_pass http://localhost:9001; } 或者使用这样的子域向 nginx 添加另一个服务器块

    server{
    
    listen 80;
    
    server_name minio.example.com;;
    
         location / {
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header X-Forwarded-Proto $scheme;
           proxy_set_header Host $http_host;
    
           proxy_pass http://localhost:9001;
       }
    }
    

    【讨论】:

    • 我确实需要它在子路径下工作,但由于不可能,我不得不接受你的回答。希望有一天它会成功!
    【解决方案2】:

    https://github.com/arschles/minio-howto/blob/master/setup-Nginx-proxy-with-Minio-Server.md

    如果您使用 nginx docker 容器,请将此文件添加到 /etc/nginx/conf.d 并删除同一目录中现有的 default.conf 文件。

    【讨论】:

      猜你喜欢
      • 2017-07-05
      • 1970-01-01
      • 2020-11-11
      • 1970-01-01
      • 2017-05-28
      • 2021-06-04
      • 1970-01-01
      • 1970-01-01
      • 2010-12-03
      相关资源
      最近更新 更多