基于Docker MinIO整合Nginx搭建反向代理
docker拉去鏡像安裝和配置就不說了
主要說一下配置反向代理
第一次使用minio我陷入了一個誤區(qū),將nginx的data目錄掛載到了minio的文件目錄,這樣是可以通過nginx訪問minio文件,但是沒有任何意義,也沒有做任何的代理設(shè)置,研究了很久最后把nginx容器停了重新run一個,然后配置以下配置完成了代理。
配置之前需要把nginx中opt/nginx文件映射到宿主機
docker run -d -p 宿主機開放的端口:80 -v/opt/nginx/nginx:/etc/nginx --restart=always
–name nginx nginx:latest
以下為opt/nginx/nginx.conf配置
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
charset utf-8,gbk;
location / {
#開啟自定義錯誤頁面
proxy_intercept_errors on;
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;
#test改成你自己的存儲桶名稱,注意:末尾需要帶有一個/
#192.168.129.203:9000修改為你自己的minio地址,注意不要填成客戶端端口。我這里是9000你可能是9090
proxy_pass http://192.168.129.203:9000/test/;
#這里也可以設(shè)置多些,如http://192.168.129.203:9000/test/test1/;
#這樣test/test1這整個文件路徑也將被隱藏。
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#客戶端緩存時間,這里設(shè)置為7天,根據(jù)自己的需要設(shè)置即可
expires 7d;
add_header XCDN-Cache "$upstream_cache_status";
#配置404頁面
error_page 404 /404.html;
}
#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 html;
}
}
配置完成后重啟一下nginx容器,然后再訪問
我minio圖片服務(wù)器是9000,nginx開放的是3344文章來源:http://www.zghlxwxcb.cn/news/detail-493456.html
可以成功訪問到了文章來源地址http://www.zghlxwxcb.cn/news/detail-493456.html
到了這里,關(guān)于基于Docker MinIO整合Nginx搭建反向代理的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!