nginx proxy minio 默认页配置(三)

还是上边的那个问题,有一些场景,我们可能需要有自己的请求路径(不使用默认的location /)
比如api 与业务系统的请求路径是分开的(前后端分开部署的系统是最典型的)

解决方法

一样还是通过url rewrite,需要解决的问题就是比以前的多了一条,我们的rewrite 也是多了一条

参考nginx 配置

 
worker_processes  1;
user root;  
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    lua_code_cache off;
    gzip  on;
    resolver 127.0.0.11 8.8.8.8 ipv6=off;          
    real_ip_header     X-Forwarded-For;
    real_ip_recursive on;
    upstream s3app {
      server s3:9000;
    }
    server {
        listen       80;
        server_name  localhost;
        charset utf-8;
        root html;
        index index.html index.htm;
        default_type text/html;
        location /apps/ {
           default_type text/html;
           index index.html index.htm;
           rewrite ^/apps/([a-zA-Z0-9]+)$ /apps/$1/ permanent;
           rewrite ^/apps/([a-zA-Z0-9]+)/$ /$1/index.html break;
           rewrite ^/apps/(.*) /$1 break;
           proxy_set_header Host $http_host;
           proxy_set_header X-Forwarded-For $remote_addr;
           client_body_buffer_size 10M;
           client_max_body_size 10G;
           proxy_buffers 1024 4k;
           proxy_read_timeout 300;
           proxy_next_upstream error timeout http_404;
           proxy_pass http://s3app;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
  • 说明
    我们约定s3 的请求都走apps,第一条rewrite 是进行添加/ 方便后续处理(使用permanent)
    第二条rewrite 是index.html的配置,第三条是对于其他请求资源的rewrite,请求到实际s3 bucket的
    位置

参考资料

https://nginx.org/en/docs/http/ngx_http_rewrite_module.html

posted on   荣锋亮  阅读(537)  评论(2编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2019-12-06 zeebe prometheus 监控配置
2019-12-06 redixdb 基于redis 协议的实时key-value 存储
2018-12-06 openresty 使用lua-resty-shell 执行shell 脚本
2018-12-06 ncm 让跨项目配置一致性简单的工具
2018-12-06 lapis 项目添加prometheus 监控集成grafana
2013-12-06 使用cglib动态创建javabean

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示