Top Menu

如何在traefik中使用子目录访问容器

最近在配置traefik使用子目录访问phpmyadmin容器时一直遇到一个问题,就是虽然使用了replacePathRegex中间件修改了路径,但是只有phpmyadmin的首页可以正常访问,一旦跳转之后就会自动进入根目录,导致进入了traefik里配置的其他规则,无法正常使用phpmyadmin,最后只能开了一个单独端口来访问,但是由于脱离了traefik的http路由,导致无法使用tls加密。

之前因为ip没办法申请证书的问题,http裸奔状态和tcp也就没啥差别,不过最近申请了一个ip的证书,准备把traefik都迁移到https上,研究了下,发现了一个解决这个问题的办法

只需要修改配置文件里一个非常小的地方

原配置文件

## Dynamic configuration ... middlewares: replacepathregex-phpmyadmin: replacePathRegex: regex: "^/phpmyadmin/(.*)" replacement: "/$1" ...

Continue Reading 0

为IP地址添加HTTPS

国内服务器不支持绑定域名,无法申请证书,不能在https页面通过js调用http的api,为了解决这个问题,去zerossl.com申请了一个ip证书。

在配置traefik的https的时候遇到了问题,最后发现在配置里的证书地址配错了,需要填写traefik的docker内地址

配置证书路径

这里在traefik的docker运行时增加一个硬盘映射:/root/traefik/dynamic:/etc/traefik/dynamic,将zerossl.com下载的证书复制到/root/traefik/dynamic/cert

## Dynamic configuration ... tls: stores: default: defaultCertificate: certFile: /etc/traefik/dynamic/cert/certificate.crt keyFile: /etc/traefik/dynamic/cert/private.key certificates: - certFile: /etc/traefik/dynamic/cert/certificate.crt keyFile: /etc/traefik/dynamic/cert/private.key ...

Continue Reading 0

使用Mortix的RPC接口添加任务

有一个需求是通过点击web页面的按钮给本机的mortix添加任务,mortix提供RPC接口,可以直接调用http://localhost:16800/jsonrpc接口

使用post方法,内容为raw-json格式

{ "jsonrpc": "2.0", "id": "qwer", "method": "aria2.addUri", "params":[["magnet:?xt=urn:btih:"]] }

Continue Reading 0

使用api向Cloud Torrent添加任务

Cloud Torrent除了支持web界面外,还有一些隐藏的api,可以通过post方式使用\

  • api address: /api/magnet
  • method: post
  • data:(raw) magnet URI

该方法可以直接向Cloud Torrent提交magnet链接,无需访问web界面

当然,如果跨域了,还需要用proxy解决跨域调用问题

jQuery实现

$("button#send").click(function(){ var myUrl = 'https://Cloud-Torrent:3000/api/magnet'; var proxy = 'https://minir.plus/cors/?url='; var finalURL = proxy + myUrl; raw=$(this).attr("data"); $.ajax({ url:finalURL, type:"POST", data:raw, contentType:"Content-Type: text/plain", dataType:"json", success: function( data, status ) { console.log("Data: " + JSON.stringify(data) + "nStatus: " + status); }}); });

Continue Reading 0

Powered by WordPress. Designed by WooThemes