-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
327 lines (261 loc) · 11.9 KB
/
Copy pathindex.html
File metadata and controls
327 lines (261 loc) · 11.9 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="author" content="wedojava" />
<title>HAProxy Simple Usage | 回风舞雪</title>
<meta name="description" content=" Reference: http://cbonte.github.io/haproxy-dconv/1.9/configuration.html#2.5
No introduce, no advanced usage, also no tutor for how to install, just config to implement proxy.
The case there is so easy so you can get sense of achivement quickly.
" />
<meta name="keywords" content="Hugo, theme, zozo, huifeng" />
<link rel="shortcut icon" href="https://huifeng.me/images/favicon.ico" />
<link rel="stylesheet" type="text/css" media="screen" href="https://huifeng.me/css/normalize.css" />
<link rel="stylesheet" type="text/css" media="screen" href="https://cdn.jsdelivr.net/npm/animate.css@4.1.0/animate.min.css" />
<link rel="stylesheet" type="text/css" media="screen" href="https://huifeng.me/css/zozo.css" />
<link rel="stylesheet" type="text/css" media="screen" href="https://huifeng.me/css/search.css" />
<link rel="stylesheet" type="text/css" media="screen" href="https://cdn.jsdelivr.net/npm/remixicon@2.5.0/fonts/remixicon.css" />
<link rel="stylesheet" type="text/css" media="screen" href="https://huifeng.me/css/highlight.css" />
</head>
<body>
<div class="main animate__animated animate__fadeInDown">
<div class="nav_container animated fadeInDown">
<div class="site_nav" id="site_nav">
<ul>
<li>
<a href="/">Home</a>
</li>
<li>
<a href="/posts/">Archive</a>
</li>
<li>
<a href="/tags/">Tags</a>
</li>
<li>
<a href="/about/">About</a>
</li>
</ul>
</div>
<div class="menu_icon">
<a id="menu_icon"><i class="ri-menu-line"></i></a>
</div>
</div>
<div class="header animated fadeInDown">
<div class="site_title_container">
<div class="site_title">
<h1>
<a href="https://huifeng.me">
<span>回风舞雪</span>
</a>
</h1>
</div>
<div class="description">
<p class="sub_title">Love My Love</p>
<div class="my_socials">
<a href="https://github.com/wedojava" title="github" target="_blank"><i class="ri-github-fill"></i></a>
<a href="https://weibo.com/wedojava" title="weibo" target="_blank"><i class="ri-weibo-fill"></i></a>
<a href="https://huifeng.me/index.xml" type="application/rss+xml" title="rss" target="_blank"><i
class="ri-rss-fill"></i></a>
</div>
</div>
</div>
</div>
<div class="content">
<div class="post_page">
<div class="post animate__animated animate__fadeInDown">
<div class="post_title post_detail_title">
<h2><a href='/posts/haproxy-simple-usage/'>HAProxy Simple Usage</a></h2>
<span class="date">2019.08.24</span>
</div>
<div class="post_content markdown"><blockquote>
<p>Reference:
<a href="http://cbonte.github.io/haproxy-dconv/1.9/configuration.html#2.5">http://cbonte.github.io/haproxy-dconv/1.9/configuration.html#2.5</a></p>
</blockquote>
<p>No introduce, no advanced usage, also no tutor for how to install, just config to implement proxy.</p>
<p>The case there is so easy so you can get sense of achivement quickly.</p>
<h1 id="my-goal">My Goal</h1>
<p>If I type <code>ssh username@127.0.0.1 -p80</code> at vps1(127.0.0.1), it’ll connect to vps2(123.123.123.123:22)!</p>
<h1 id="conditions">Conditions</h1>
<ol>
<li>vps1’s port 80 is open</li>
<li>vps2’s port 22 is open</li>
<li>haproxy was installed in vps1(127.0.0.1)</li>
</ol>
<h1 id="configuration">Configuration</h1>
<div class="highlight"><pre class="chroma"><code class="language-fallback" data-lang="fallback">global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate
ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
ssl-default-bind-options no-sslv3 no-tlsv10 no-tlsv11 no-tls-tickets
defaults
log global
mode http
# option httplog
# option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
frontend tcp-33-front
bind *:33
mode tcp
default_backend tcp-33-back
backend tcp-33-back
mode tcp
server tcp-33 123.123.123.123:22 check
listen test
bind *:80
mode tcp
server centos 123.123.123.123:22 check port 22 inter 5000 fall 5
</code></pre></div><p>Then, run the command below to verify the syntex is right.</p>
<div class="highlight"><pre class="chroma"><code class="language-fallback" data-lang="fallback">haproxy -f /etc/haproxy/haproxy.cfg -c
</code></pre></div><p>No error occur, yeap, run it!</p>
<div class="highlight"><pre class="chroma"><code class="language-fallback" data-lang="fallback">haproxy -f /etc/haproxy/haproxy.cfg
</code></pre></div><p>Now, you can run <code>ssh -p33 vagrant@127.0.0.1</code> or <code>ssh -p80 vagrant@127.0.0.1</code> to connect to vps2(123.123.123.123) on ssh:22.</p>
<h1 id="simple-working-principle">Simple Working Principle</h1>
<p>This is core config:</p>
<div class="highlight"><pre class="chroma"><code class="language-fallback" data-lang="fallback">frontend tcp-33-front
bind *:33
mode tcp
default_backend tcp-33-back
backend tcp-33-back
mode tcp
server tcp-33 123.123.123.123:22 check
listen test
bind *:80
mode tcp
server centos 123.123.123.123:22 check port 22 inter 5000 fall 5
</code></pre></div><p>also, you can just use one part of it!</p>
<p>listen style: All data access to port 80 will pass to 22!</p>
<div class="highlight"><pre class="chroma"><code class="language-fallback" data-lang="fallback">listen test
bind *:80
mode tcp
server centos 123.123.123.123:22 check port 22 inter 5000 fall 5
</code></pre></div><p>OR</p>
<p>All data access to port 33 will pass to 22!</p>
<div class="highlight"><pre class="chroma"><code class="language-fallback" data-lang="fallback">frontend tcp-33-front
bind *:33
mode tcp
default_backend tcp-33-back
backend tcp-33-back
mode tcp
server tcp-33 123.123.123.123:22 check
</code></pre></div><p>haproxy process look up: <code>ps -ef | grep haproxy</code> .</p>
<h1 id="bind-ports">Bind ports!</h1>
<p>Reference: <a href="http://cbonte.github.io/haproxy-dconv/1.8/configuration.html#bind">http://cbonte.github.io/haproxy-dconv/1.8/configuration.html#bind</a></p>
<blockquote>
<p>It is possible to specify a list of address:port combinations delimited by
commas. There is no
fixed limit to the number of addresses and ports which can be listened on in
a frontend, as well as there is no limit to the number of “bind” statements
in a frontend.</p>
</blockquote>
<p>SO, YOU CAN WRITE frontend like this:</p>
<div class="highlight"><pre class="chroma"><code class="language-fallback" data-lang="fallback">bind :33, :44
bind 10.0.0.1:55, 10.0.0.1:66
</code></pre></div><p>EOF</p></div>
<div class="post_footer">
<div class="meta">
<div class="info">
<span class="field tags">
<i class="ri-stack-line"></i>
<a href="https://huifeng.me/tags/haproxy/">HAProxy</a>
<a href="https://huifeng.me/tags/proxy/"> proxy</a>
<a href="https://huifeng.me/tags/example/"> example</a>
</span>
</div>
</div>
</div>
</div>
<div class="doc_comments">
<div class="comments_block_title">发表评论</div>
<div id="vcomments"></div>
</div>
<link rel="stylesheet" href="https://huifeng.me/css/comments.css" />
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='//unpkg.com/valine/dist/Valine.min.js'></script>
<script type="text/javascript">
new Valine({
el: '#vcomments',
appId: 'yusajl3uDsnB888cn1ulQeKz-gzGzoHsz',
appKey: 'jYjHeNB1qVYREHe1zX4bRx7z',
placeholder: ' ',
visitor: 'true',
})
</script>
</div>
</div>
</div>
<a id="back_to_top" href="#" class="back_to_top"><i class="ri-arrow-up-s-line"></i></a>
<footer class="footer">
<div class="powered_by">
<a href="https://varkai.com">Designed by VarKai,</a>
<a href="http://www.gohugo.io/">Proudly published with Hugo</a>
</div>
<div class="footer_slogan">
<span>>_ Simple Is Correct.</span>
</div>
</footer>
<div id="fastSearch">
<input id="searchInput" tabindex="0">
<ul id="searchResults">
</ul>
</div>
<script src="/js/fuse.js"></script>
<script src="/js/fastsearch.js"></script>
<script src="https://huifeng.me/js/jquery-3.5.1.min.js"></script>
<link href="https://huifeng.me/css/fancybox.min.css" rel="stylesheet">
<script src="https://huifeng.me/js/fancybox.min.js"></script>
<script src="https://huifeng.me/js/zozo.js"></script>
<script type="text/javascript" async
src="https://cdn.bootcss.com/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$', '$$'], ['\[\[', '\]\]']],
processEscapes: true,
processEnvironments: true,
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
TeX: {
equationNumbers: { autoNumber: "AMS" },
extensions: ["AMSmath.js", "AMSsymbols.js"]
}
}
});
MathJax.Hub.Queue(function () {
var all = MathJax.Hub.getAllJax(), i;
for (i = 0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
</script>
<style>
code.has-jax {
font: inherit;
font-size: 100%;
background: inherit;
border: inherit;
color: #515151;
}
</style>
</body>
</html>