Site updated: 2022-09-27 15:13:02
This commit is contained in:
101
rss.xml
101
rss.xml
@ -10,8 +10,8 @@
|
||||
</author>
|
||||
<description>hito的博客</description>
|
||||
<language>zh-CN</language>
|
||||
<pubDate>Mon, 26 Sep 2022 19:30:00 +0800</pubDate>
|
||||
<lastBuildDate>Mon, 26 Sep 2022 19:30:00 +0800</lastBuildDate>
|
||||
<pubDate>Tue, 27 Sep 2022 14:45:00 +0800</pubDate>
|
||||
<lastBuildDate>Tue, 27 Sep 2022 14:45:00 +0800</lastBuildDate>
|
||||
<category term="hito" />
|
||||
<category term="無言" />
|
||||
<category term="博客" />
|
||||
@ -19,6 +19,103 @@
|
||||
<category term="笔记" />
|
||||
<category term="心得体会" />
|
||||
<category term="踩坑" />
|
||||
<item>
|
||||
<guid isPermalink="true">https://blog.jingxiyuan.cn/2022/09/27/nginx%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1%E9%85%8D%E7%BD%AE/</guid>
|
||||
<title>nginx负载均衡配置</title>
|
||||
<link>https://blog.jingxiyuan.cn/2022/09/27/nginx%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1%E9%85%8D%E7%BD%AE/</link>
|
||||
<category term="技术分享" scheme="https://blog.jingxiyuan.cn/categories/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/" />
|
||||
<category term="nginx" scheme="https://blog.jingxiyuan.cn/tags/nginx/" />
|
||||
<category term="负载均衡" scheme="https://blog.jingxiyuan.cn/tags/%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/" />
|
||||
<pubDate>Tue, 27 Sep 2022 14:45:00 +0800</pubDate>
|
||||
<description><![CDATA[ <h2 id="nginx负载均衡配置"><a class="anchor" href="#nginx负载均衡配置">#</a> nginx 负载均衡配置</h2>
|
||||
<ol>
|
||||
<li>轮询(默认)</li>
|
||||
</ol>
|
||||
<p> <em>每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器 down 掉,能自动剔除。</em></p>
|
||||
<pre><code class="language-yum">upstream my_server &#123;
|
||||
server 192.168.0.2:8080;
|
||||
server 192.168.0.3:8080;
|
||||
&#125;
|
||||
|
||||
server &#123;
|
||||
listen 80;
|
||||
server_name 192.168.0.1;
|
||||
|
||||
# Path to the root of your installation
|
||||
location / &#123;
|
||||
proxy_pass http://my_server;
|
||||
&#125;
|
||||
|
||||
&#125;
|
||||
</code></pre>
|
||||
<ol start="2">
|
||||
<li>weight 权重策略</li>
|
||||
</ol>
|
||||
<p> <em>weight 代表权重,默认为 1,权重越高被分配的客户端越多,指定轮询几率。weight 和访问比率成正比,用于后端服务器性能不均的情况。</em></p>
|
||||
<pre><code class="language-yum">upstream my_server &#123;
|
||||
server 192.168.0.2:8080 weight=1;
|
||||
server 192.168.0.3:8080 weight=2;
|
||||
&#125;
|
||||
|
||||
server &#123;
|
||||
listen 80;
|
||||
server_name 192.168.0.1;
|
||||
|
||||
# Path to the root of your installation
|
||||
location / &#123;
|
||||
proxy_pass http://my_server;
|
||||
&#125;
|
||||
|
||||
&#125;
|
||||
</code></pre>
|
||||
<ol start="3">
|
||||
<li>ip_hash</li>
|
||||
</ol>
|
||||
<p> <em>每个请求按访问 ip 的 hash 结果分配,这样每个访客固定访问一个后端服务器,可以解决 session 的问题。</em></p>
|
||||
<pre><code class="language-yum">upstream my_server &#123;
|
||||
ip_hash;
|
||||
server 192.168.0.2:8080;
|
||||
server 192.168.0.3:8080;
|
||||
&#125;
|
||||
|
||||
server &#123;
|
||||
listen 80;
|
||||
server_name 192.168.0.1;
|
||||
|
||||
# Path to the root of your installation
|
||||
location / &#123;
|
||||
proxy_pass http://my_server;
|
||||
&#125;
|
||||
|
||||
&#125;
|
||||
</code></pre>
|
||||
<ol start="4">
|
||||
<li>fair (第三方)</li>
|
||||
</ol>
|
||||
<p> <em>按后端服务器的响应时间来分配请求,响应时间短的优先分配。</em></p>
|
||||
<pre><code class="language-yum">upstream my_server &#123;
|
||||
server 192.168.0.2:8080;
|
||||
server 192.168.0.3:8080;
|
||||
fair;
|
||||
&#125;
|
||||
|
||||
server &#123;
|
||||
listen 80;
|
||||
server_name 192.168.0.1;
|
||||
|
||||
# Path to the root of your installation
|
||||
location / &#123;
|
||||
proxy_pass http://my_server;
|
||||
&#125;
|
||||
|
||||
&#125;
|
||||
</code></pre>
|
||||
<ol start="5">
|
||||
<li>动静分离</li>
|
||||
</ol>
|
||||
<p> <em>把静态的资源,比如图片,css,js 等先加载到 Nginx 的服务器里。</em></p>
|
||||
]]></description>
|
||||
</item>
|
||||
<item>
|
||||
<guid isPermalink="true">https://blog.jingxiyuan.cn/2022/09/26/%E8%A7%A3%E5%86%B3Hexo-Shoka%E8%83%8C%E6%99%AF%E9%9F%B3%E4%B9%90%E6%97%A0%E6%B3%95%E6%92%AD%E6%94%BE%E7%9A%84%E9%97%AE%E9%A2%98/</guid>
|
||||
<title>解决Hexo+Shoka背景音乐无法播放的问题</title>
|
||||
|
Reference in New Issue
Block a user