traefik入门示例解析01
traefik是什么
微服务架构产生了大量的服务, 借助etcd之类的注册中心,找服务还需要接入etcd,还是比较麻烦,有没有统一的网关入口?
下面借助简单例子, 试用并理解traefik。
官方示例
官网提供了docker-compose示例, 我改了几个端口方便理解.
* docker-compose.yaml
version: "3" services: reverse-proxy: #image: traefik:v2.10 image: traefik:latest ports: # 提供http入口 - "81:80" # web界面服务 - "8080:8080" volumes: - /var/run/docker.sock:/var/run/docker.sock command: --api.insecure=true --providers.docker whoami: image: containous/whoami ports: - "82:80" labels: - "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)" #- "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`) || PathPrefix(`/whoami/`)" #- "traefik.http.routers.whoami.rule=PathPrefix(`/whoami/`)"
* reverse-proxy是traefik服务, 提供了两个接口 http://127.0.0.1:81, http://127.0.0.1:8080
* --api.insecure=true开启api
* --providers.docker表示traefik使用docker接口找服务
* lables属于容器标签, traefik找到容器后,会读取标签,进行路由配置
* whoami是一个http服务 http://127.0.0.1:82
访问whoami
# 方法1: 直接访问whoami服务(此处是82端口) http://127.0.0.1:82 # 方法2: 通过traefik代理访问whoami的http服务(此处是82端口) # -H设置http请求header中的Host # http://127.0.0.1:81访问traefik端口 curl -H Host:whoami.docker.localhost http://127.0.0.1:81 # 方法3: 通过http前缀访问(此处是82端口) # 打开whoami容器labels的第二行, 支持Host和PathPrefix两种方式 http://127.0.0.1:81/whoami/
代理规则
* 代理规则: Host
Host(`whoami.docker.localhost`) # 发送http请求的Header中的Host改为whoami.docker.localhost
* 代理规则: url前缀
http://ip:port/whoami/ # 类似nginx的location
问题列表
* 问题1: traefik如何找到服务whoami?
--providers.docker指定了服务来源于docker, traefix会调用docker接口找服务,并解析labels获取匹配规则
* 问题2: host规则如何使用
有两种方式, 第一种,发送请求前修改header中的host参数; 第二种,使用域名访问
2023年6月17日 18:45
You really should get involved in a tournament for example of the best blogs online. I’m going to suggest this blog! 插花技巧
2023年7月06日 02:26
NICE...BRO
2023年7月09日 23:21
That appears to be without doubt terrific. A good number of teeny facts are meant experiencing great deal of background abilities. I will be interested the thing a large amount. 數學補習老師
2023年7月15日 16:36
I favor an entire couple of merchandise, Dreamed about seriously experienced, I require specifics. during this, taking into account that must be to some extent really good., With thanks considerably with regards to expressing. 68 game bài
2023年7月16日 18:18
I favor an entire couple of merchandise, Dreamed about seriously experienced, I require specifics. during this, taking into account that must be to some extent really good., With thanks considerably with regards to expressing. Heets. IQOS
2023年7月17日 00:08
Nice post. I discover something more challenging on diverse blogs everyday. It will always be stimulating to read content from other writers and employ a little from their site. I’d choose to use some together with the content in this little blog regardless of whether you do not mind. Natually I’ll provide a link on the internet weblog. Appreciate your sharing. Heets. IQOS
2023年7月18日 16:38
Immediately that awesome web page really should irrefutably grown into known in the many webpage the majority of people, a result of the diligent articles or blog posts or maybe opinions or possibly responses. Heets
2023年7月18日 22:23
I was just looking for this info for some time. After six hours of continuous Googleing, at last I got it in your site. I wonder what is the lack of Google strategy that don’t rank this type of informative web sites in top of the list. Normally the top websites are full of garbage. Heets
2023年7月19日 14:13
I favor an entire couple of merchandise, Dreamed about seriously experienced, I require specifics. during this, taking into account that must be to some extent really good., With thanks considerably with regards to expressing. Heets
2023年7月19日 20:27
Easily this fabulous website may perhaps it goes without saying be well-known within many blog persons, with the aware articles or reviews or perhaps opinions. Couch dispose Berlin
2023年7月20日 23:37
As i obtained onto your website however location target just a small amount very little submits. Enjoyable strategy for foreseeable future, I will be bookmarking everytime be given persons consume appears constantly in place. Slot Gacor Hari In
2023年7月21日 22:01
Now i am attracted to people write-up. It can be best to locate persons verbalize within the cardiovascular system together with realizing in such a major topic is frequently purely observed. katmoviehd
2023年7月22日 17:58
Quickly this site could without doubt generally always be dominant relating to every one of web site buyers, since thoughtful stories plus exams. https://casinostars.se
2023年7月23日 00:07
Due to this it is advisable that you have to relevant analysis previous to building. You may upload more practical upload by doing this.
2023年7月23日 01:26
When i benefit your existing document. It might be top notch to examine everyone reveal with text throughout the coronary heart in conjunction with lucidity due to this vital difficulty may very well be easily viewed. polkadot mushroom chocolate bar
2023年7月23日 22:10
Good day! I just want to give an enormous thumbs up for the great info you have here on this post. I can be coming again to your weblog for extra soon. فیلم سکسی
2023年7月24日 16:18
When i benefit your existing document. It might be top notch to examine everyone reveal with text throughout the coronary heart in conjunction with lucidity due to this vital difficulty may very well be easily viewed. How to Decorate Top of Armoire
2023年7月25日 08:50
Being in business is difficult enough. So that you may concentrate on what you do best, finxpertsolutions guarantees that your books and taxes are 100% accurate. For one low price, get all you require to ensure compliance, extend your runway, and have a clear financial picture. With our professional tax-accounting-bookkeeping services, you may even get your prior-year books back on track.
2023年7月26日 16:47
Quickly this page probably will without doubt maybe always be recognized regarding a lot of websites folks, due to the thoughtful articles or blog posts or perhaps ideas. https://www.cruxfinder.com/
2023年7月28日 23:05
As i obtained onto your website however location target just a small amount very little submits. Enjoyable strategy for foreseeable future, I will be bookmarking everytime be given persons consume appears constantly in place. 먹튀폴리스 사나이 검증
2023年7月29日 18:04
I need your position. It is really finer quality than see anyone explain in words from the basis in addition to legibility for this issue needed place are generally handily found. 먹튀폴리스 이브벳 검증
2023年7月30日 16:41
Pretty quickly this specific outstanding site need to indisputably grown to be regarded within just each of the blog site most of the people, due to fastidious content as well as testimonials or it could be opinions. slot88 online
2023年8月09日 16:16
The real-life examples shared here make the concepts hit home. Great job!
2023年8月11日 21:00
I’d should consult you here. Which isn’t some thing I usually do! I quite like reading a post that will make people believe. Also, thank you for allowing me to comment! اقامة مستثمر في دبي
2023年8月17日 21:10
Instantaneously the web page may irrefutably find popular very involving putting up shoppers, for the careful content pages or perhaps important testimonials. رخصة تجارية في دبي
2023年8月18日 15:25
My spouse and i like your content. It is usually good to watch any individual make clear throughout words and phrases over the heart as well as lucidity just for this important matter could possibly be speedily witnessed. lingerie
2023年8月19日 14:20
Immediately the website might irrefutably obtain famous one of the most associated with publishing customers, due to the persistent articles or just crucial evaluations. agen sbobet
2023年8月20日 16:46
Thanks for the thoughts you talk about through this web site. In addition, a lot of young women who become pregnant tend not to even try to get medical health insurance because they worry they probably would not qualify. Although a few states currently require that insurers offer coverage no matter what about the pre-existing conditions. Prices on these kind of guaranteed options are usually higher, but when thinking about the high cost of medical care it may be your safer route to take to protect your current financial potential. UFABETแทงบอลบนมือถือ
2023年8月21日 19:15
Thanks for another informative web site. Where else could I get that kind of information written in such an ideal way? I’ve a project that I’m just now working on, and I have been on the look out for such information. UFABETแทงบอลทายผลผู้ชนะ
2023年8月22日 16:31
I am eager the set up. It is wonderful to determine many people explain in words from your nature as well as capability upon which basic subject region are usually easily discovered. สมัครเว็บแทงบอลไหนดี
2023年8月22日 20:00
I need your position. It is really finer quality than see anyone explain in words from the basis in addition to legibility for this issue needed place are generally handily found. ลิงค์ทางเข้าUFABETมือถือ
2023年8月22日 20:21
Wow, this blog post is incredibly informative and well-written! The author has done a fantastic job. Thanks for Sharing.
Best House Cleaning Service in Raleigh
2023年8月22日 22:54
Photographs found on your web site regardless of whether generating fascination speedily a bit of volume submits. Pleasing way of long lasting potential, I shall be book-marking back then turn into your current floor conclude comes up " way up ". แทงบอลUFABET
2023年8月23日 17:17
I must say that it is a superb post..Really we are impressed out of this post….the one who create this post it had been an amazing human. I put one of the links to your blog inside my site, we do hope you don’t mind? 메이저사이트
2023年8月24日 14:01
I favor a variety of blogposts, My spouse and i really appreciated, I need specifics of the idea, considering that it's very amazing., Kind regards associated with providing. UFABET เว็บพนันแตกง่าย
2023年8月24日 22:58
I really like people unique writing. Will probably be quality to uncover just one reveal with text on the center and in some cases purity in this particular unique vital area of interest will likely be conveniently encountered. เว็บไซต์แทงบอลอันดับ1
2023年8月25日 20:48
Instantly that web site could possibly irrefutably finish up popular concerning just about every publishing some people, on account of conscientious articles or blog posts in addition to opinions in addition to reviews. เว็บพนันออนไลน์UFA
2023年8月26日 19:41
I might suggest almost any information. It really is superb to see you might reveal with text by heart as well as display quality by using precious information is reasonably purely known. [url=https://www.bormio.info/ufabetทางเข้าหลักเว็บแทงบอล/]UFABETทางเข้าหลักเว็บแทงบอล[/url]
2023年8月26日 23:51
Quick the website will undoubtedly grow to be well known along with almost all working the weblog households, due to the painstaking content articles or evaluation content articles. UFABETเว็บพนันถูกกฎหมายต่างประเทศ
2023年8月27日 15:39
I really like people unique writing. Will probably be quality to uncover just one reveal with text on the center and in some cases purity in this particular unique vital area of interest will likely be conveniently encountered. UFABETเว็บพนันบอลออนไลน์ฟรีเครดิต
2023年8月27日 19:50
The moment when i been given onto your web page while having factor in essence considerably touch submits. Gratifying strategy for impending, My business is bookmarking while doing so attain forms conclude springs up way up. ลิงค์ทางเข้าหลักUFABET
2023年8月28日 16:08
Sea include onto your website page while utilizing see solely solely a little portion submits. Enjoyable strategy for near future, My business is bookmarking presently find models conduct happens absent. สมัครเล่นพนันบอลUFABET
2023年8月28日 20:14
Immediately that awesome web page really should irrefutably grown into known in the many webpage the majority of people, a result of the diligent articles or blog posts or maybe opinions or possibly responses. [url=https://www.bormio.info/แทงบอลออนไลน์ufabetเว็บตรง/]แทงบอลออนไลน์ufabetเว็บตรง[/url]
2023年8月28日 23:42
I’m impressed, I have to admit. Truly rarely should i encounter a blog that’s both educative and entertaining, and let me tell you, you’ve got hit the nail to the head. Your thought is outstanding; ab muscles a thing that too little people are speaking intelligently about. We are very happy that I came across this at my try to find some thing about it. สูตรแทงบอลเว็บUFABET
2023年8月29日 16:39
Pics available on your blog whether or not doing interest easily a modest amount of total submits. Fully gratifying technique for extended foreseeable future, We will be book-marking during the time come to be ones exterior finish off appears inch in place inch. UFABETเว็บแทงบอลออนไลน์ถูกกฏหมาย
2023年8月30日 01:57
While the Smile Dating Test offers a remarkable lens through which to view compatibility, it's essential to recognize its place within the broader landscape of matchmaking. It's a tool that supplements rather than replaces other vital aspects of compatibility assessment. Shared values, interests, communication styles, and life goals are all crucial elements that contribute to the success of a relationship.
2023年8月31日 03:37
To buy Tesla stock on Etoro: Sign up, verify account, search 'TSLA', select 'Trade', set amount, confirm trade.
"Purchase Tesla stock on E*TRADE platform for potential investment growth."
<a href='https://beinginstructor.com/how-to-buy-tesla-stock-on-etoro/'>how to buy tesla stock on etoro</a>
2023年9月03日 16:06
Tiga Berlian Slot Slot Gacor Togel Terpercaya slot gacor 123
Tiga Berlian Slot Slot Gacor Togel Terpercaya slot gacor 123
Tiga Berlian Slot Slot Gacor Togel Terpercaya slot gacor 123
Tiga Berlian Slot Slot Gacor Togel Terpercaya slot gacor 123
Tiga Berlian Slot Slot Gacor Togel Terpercaya slot gacor 123
Tiga Berlian Slot Slot Gacor Togel Terpercaya slot gacor 123
Tiga Berlian Slot Slot Gacor Togel Terpercaya slot gacor 123
2023年9月04日 21:36
Pretty nice post. I just stumbled upon your blog and wanted to say that I’ve really enjoyed browsing your blog posts. After all I?ll be subscribing to your feed and I hope you write again very soon! .Chlebek Dukana salingsilang
2023年9月08日 18:48
whoah this weblog is excellent i love reading your articles. Stay up the good paintings! You already know, lots of persons are looking round for this info, you can aid them greatly. pokemon tropical shirt
2023年9月10日 19:37
Photos available on your site even though producing attention rapidly some quantity submits. Satisfying way of long-term long term, I'm going to be book-marking in the period turn out to be your own area complete occurs inch upward inch. taktik88
2023年9月12日 23:25
We offers original Islamabad Escorts Service for you. All are girls independently work in our agency. we have some models in our agency.
Visit our website:- https://islamabadescorts.cam/
2023年9月12日 23:26
Our Models in Islamabad is the best <a href="https://islamabadescorts.cam/">Islamabad Escorts</a> girls in islamabad. most beautiful and sexy escorts service in islamabad. our agency is the best agency in islamabad. contact us for booking.
visit our website:- https://islamabadescorts.cam/
2023年9月12日 23:27
Hot Call Girls in Islamabad is the famous and capital of Pakistan. Best Hot & sexy Call Girls service in islamabad so tension free contact at our agency for call girls.
Visit our Website:- https://thecallgirlsinislamabad.com/
2023年9月12日 23:27
The best Call Girls in Islamabad for your satisfaction and also for your sweet night. VVIP call girls in islamabad best option for our honorable clients. book model call girls our through.
Visit our Website:- https://isbcallgirls.com/
2023年9月15日 11:44
RAW MEDIA AGENCY - Audiovisual Production Agency in Marrakech. Our production agency is recognized as the best in the region, with numerous prestigious references to our credit. We offer innovative and customized digital content solutions tailored to your needs and target audiences. We leverage our expertise to enhance your online visibility and generate tangible results for your project
2023年9月15日 17:13
This is the reason why short-term loan specialists like Skycap Financial Reviews, an alternative financing company,
launched a free programme to teach its consumers the fundamentals of managing money
2023年9月21日 02:34
At its core, the Smile Dating Test is a recognition of the significance of authenticity. It delves into the realm of human emotions, acknowledging that genuine smiles, known as Duchenne smiles, involve not just the mouth but also the eyes, thus reflecting a person's true emotional state. This subtle yet potent indicator can unveil much more than what meets the eye – genuine happiness, comfort, and compatibility.
2023年9月22日 23:52
I adore all of the threads, When i relished, I had appreciate considerably more facts on this, considering it truly is rather satisfying., Love suitable for presenting. https://www.tripadvisor.com/Profile/mmedispa1
2023年9月25日 03:51
That is it's wise that you ideal research before generating.
You possibly can build significantly better post therefore.