在使用WSL的Windows机器中,我有两个Docker容器Minio和Nginx。容器名称为Minio和Nginx-Proxy。可以使用Http://127.0.0.1:9001/login和http:// localhost:9001/login访问Minio。在添加C:\ Windows \ System32 \驱动程序TC \ Hosts中的127.0.0.1 Minio时,可以访问URL为http:// minio:9001/login.
使用以下命令创建Docker容器
docker run -d -p 9000:9000 -p 9001:9001 --name minio --network minio-net -v /mnt/c/minio/data:/data -e "MINIO_ROOT_USER=minioadmin" -e "MINIO_ROOT_PASSWORD=minioadmin" quay.io/minio/minio server /data --console-address ":9001"
docker run -d --name nginx-proxy --network minio-net -p 443:443 -p 80:80 nginx
我修改了nginx/conf.d/default.confto
server {
listen 80;
listen [::]:80;
server_name minio;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /login {
proxy_pass http://minio:9001/login;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
reloded nginx容器
docker exec nginx-proxy nginx -t docker exec nginx-proxy nginx -s reload
日志如下如nginx
2025/02/22 18:51:51 [notice] 1#1: signal 17 (SIGCHLD) received from 49
2025/02/22 18:51:51 [notice] 1#1: worker process 49 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: signal 29 (SIGIO) received
2025/02/22 18:51:51 [notice] 1#1: signal 17 (SIGCHLD) received from 52
2025/02/22 18:51:51 [notice] 1#1: worker process 52 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: signal 29 (SIGIO) received
2025/02/22 18:51:51 [notice] 1#1: signal 17 (SIGCHLD) received from 51
2025/02/22 18:51:51 [notice] 1#1: worker process 50 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: worker process 51 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: signal 29 (SIGIO) received
2025/02/22 18:51:51 [notice] 1#1: signal 17 (SIGCHLD) received from 55
2025/02/22 18:51:51 [notice] 1#1: worker process 55 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: signal 29 (SIGIO) received
2025/02/22 18:51:51 [notice] 1#1: signal 17 (SIGCHLD) received from 53
2025/02/22 18:51:51 [notice] 1#1: worker process 53 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: signal 29 (SIGIO) received
2025/02/22 18:51:51 [notice] 1#1: signal 17 (SIGCHLD) received from 56
2025/02/22 18:51:51 [notice] 1#1: worker process 56 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: signal 29 (SIGIO) received
2025/02/22 18:51:51 [notice] 1#1: signal 17 (SIGCHLD) received from 54
2025/02/22 18:51:51 [notice] 1#1: worker process 54 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: signal 29 (SIGIO) received
我应该做什么以查看http:// minio/登录中的URL,因为当前抛出404ERROR
server {
listen 80;
server_name minio;
location / {
proxy_pass http://minio:9000;
proxy_set_header Host $host;
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;
}
location /login {
proxy_pass http://minio:9001;
proxy_set_header Host $host;
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;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
修改配置后,重新加载nginx:
docker exec nginx-proxy nginx -s reload
现在访问minio atinio。