hexo/posts/57ea9005.html

508 lines
24 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="zh-CN">
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="icon" href="/img/logo.png">
<meta name="author" content="浪子">
<meta name="subtitle" content="一个分享自己生活的博客">
<meta name="description" content="曾梦想仗剑走天涯;因太胖放弃原计划.">
<meta name="keywords" content=",DIY,黑苹果,分享,自由">
<link rel="alternate" href="/atom.xml " title="提剑追梦" type="application/atom+xml">
<title>Docker部署Activity-Relay服务 | 提剑追梦</title>
<link rel="stylesheet" href="/css/style.css" >
<link rel="stylesheet" href="/css/partial/dark.css" >
<link rel="stylesheet" href="/css/partial/highlight/atom-one-light.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css">
<link rel="stylesheet" href="https://cdnjs.sgcd.net/lxgw-wenkai-screen-webfont/lxgwwenkaigbscreen.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/a2396837/CDN@latest/css/iconfont.css">
<script src="/js/todark.js"></script>
<meta name="generator" content="Hexo 6.3.0"></head>
</html>
<div class="nav index" style="height: 60px;">
<div class="title animated fadeInDown">
<div class="layui-container">
<div class="nav-title"><a href="/" title="提剑追梦">提剑追梦</a></div>
<div class="nav-list">
<button> <span class=""></span><span style="display: block;"></span><span class=""></span> </button>
<ul class="layui-nav" lay-filter="">
<li class="layui-nav-item">
<a href="/ ">
<i class=" fab fa-fort-awesome " style="color: rgb(255 107 107);"></i>
<span class="layui-nav-item-name">首页</span>
</a>
</li>
<li class="layui-nav-item">
<a href="/archives/ ">
<i class=" fas fa-archive " style="color: rgb(10 189 227);"></i>
<span class="layui-nav-item-name">归档</span>
</a>
</li>
<li class="layui-nav-item">
<a href="/tags/ ">
<i class=" fas fa-hashtag " style="color: rgb(254 202 87);"></i>
<span class="layui-nav-item-name">标签</span>
</a>
</li>
<li class="layui-nav-item">
<a href="/fcircle/ ">
<i class=" fas fa-heart " style="color: rgb(29 209 161);"></i>
<span class="layui-nav-item-name">朋友圈</span>
</a>
</li>
<li class="layui-nav-item">
<a href="/links/ ">
<i class=" fab fa-weixin " style="color: hsl(152deg 73% 45%);"></i>
<span class="layui-nav-item-name">友链</span>
</a>
</li>
<li class="layui-nav-item">
<a href="/memos/ ">
<i class=" fas fa-coffee " style="color:#31c7c1;"></i>
<span class="layui-nav-item-name">说说</span>
</a>
</li>
<li class="layui-nav-item">
<a href="/about/ ">
<i class=" fab fa-grav " style="color: rgb(154 106 247);"></i>
<span class="layui-nav-item-name">关于</span>
</a>
</li>
<li class="layui-nav-item" id="btn-toggle-dark">🌙</li>
<span class="layui-nav-bar" style="left: 342px; top: 78px; width: 0px; opacity: 0;"></span>
</ul>
</div>
</div>
</div>
</div>
<header class="header">
<div class="logo">
<a href="/"><img src="https://img.imsun.org/avatar.jpg" onerror=this.onerror=null,this.src="/img/loading.gif"></a>
</div>
</div>
<div class="motto">
<span>曾梦想仗剑走天涯</span>
</div>
<div class="social">
<a class="social-icon" href="https://github.com/jkjoy" target="_blank" title="Github">
<i class="iconfont icon-GitHub" aria-hidden="true"></i>
</a>
<a class="social-icon" href="mailto:jkjoy@163.com" target="_blank" title="Email">
<i class="iconfont icon-email" aria-hidden="true"></i>
</a>
<a class="social-icon" href="/atom.xml" target="_blank" title="rss">
<i class="iconfont icon-rss" aria-hidden="true"></i>
</a>
</div>
</header>
<article id="post">
<div class="post-title">Docker部署Activity-Relay服务</div>
<div class="post-meta">
<div class="post-meta-item date">
<span title="发表于 2023.10.03"><i class="far fa-calendar-alt"></i> 2023.10.03</span>
</div>
<div class="post-meta-item updated">
<span title="更新于 2024.06.18"><i class="far fa-calendar-check"></i> 2024.06.18</span>
</div>
<div class="post-meta-item categories">
<i class="fas fa-inbox article-meta__icon"></i> <a href="/categories/%E5%88%86%E4%BA%AB/">分享</a>
</div>
<div class="post-meta-item wordcount">
<i class="fas fa-pencil-alt"></i> <span class="post-count">337 字</span>
<i class="far fa-clock"></i> <span class="post-count">1 分钟</span>
</div>
</div>
<div class="content">
<blockquote><h3>自动摘要</h3>
ai: 这篇文章介绍了在中国大陆部署具体软件时遇到的通讯问题并详述了在CentOS 7.9系统上的部署过程包括所需的准备工作如安装git、openssl等从仓库拉取代码编辑配置文件生成RSA证书以及构建镜像和运行服务的步骤。此外文章还提供了检查容器状态、停止服务和一些相关配置参考如docker-compose和Nginx的设置。
</blockquote>
<div><ul>
<li>经过测试国内部署会有无法通讯的问题.</li>
</ul>
<h2 id="测试环境"><a href="#测试环境" class="headerlink" title="测试环境"></a>测试环境</h2><p>centos7.9</p>
<h2 id="准备工作"><a href="#准备工作" class="headerlink" title="准备工作"></a>准备工作</h2><ul>
<li>git</li>
<li>openssl</li>
<li>nginx</li>
<li>docker</li>
<li>docker-compose</li>
</ul>
<h2 id="从仓库Pull-a-repository"><a href="#从仓库Pull-a-repository" class="headerlink" title="从仓库Pull a repository"></a>从仓库Pull a repository</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git clone https://github.com/yukimochi/Activity-Relay.git -b v2.0.0</span><br></pre></td></tr></table></figure>
<h2 id="复制编辑config-yml"><a href="#复制编辑config-yml" class="headerlink" title="复制编辑config.yml"></a>复制编辑config.yml</h2><p>进入<code>Activity-Relay</code>目录</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd Activity-Relay</span><br><span class="line">cp config.yml.example config.yml</span><br></pre></td></tr></table></figure>
<p>修改相关配置</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim config.yml</span><br></pre></td></tr></table></figure>
<h2 id="生成actor-RSA-证书-x2F-actor-pem"><a href="#生成actor-RSA-证书-x2F-actor-pem" class="headerlink" title="生成actor RSA 证书 .&#x2F;actor.pem"></a>生成actor RSA 证书 .&#x2F;actor.pem</h2><p>ubuntu使用</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">openssl genrsa -traditional | tee actor.pem</span><br></pre></td></tr></table></figure>
<p>centos使用</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">openssl genrsa -out actor.pem 1024 | tee actor.pem</span><br></pre></td></tr></table></figure>
<p>赋予权限600</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">chmod 600 actor.pem</span><br></pre></td></tr></table></figure>
<h2 id="构建镜像与运行服务"><a href="#构建镜像与运行服务" class="headerlink" title="构建镜像与运行服务"></a>构建镜像与运行服务</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker-compose build</span><br><span class="line">docker-compose up -d</span><br></pre></td></tr></table></figure>
<h2 id="查看容器运行状态"><a href="#查看容器运行状态" class="headerlink" title="查看容器运行状态"></a>查看容器运行状态</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker-compose ps</span><br></pre></td></tr></table></figure>
<h2 id="停止服务"><a href="#停止服务" class="headerlink" title="停止服务"></a>停止服务</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker-compose down</span><br></pre></td></tr></table></figure>
<h2 id="相关参考"><a href="#相关参考" class="headerlink" title="相关参考"></a>相关参考</h2><p>docker-compose配置</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">version: &quot;2.3&quot;</span><br><span class="line">services:</span><br><span class="line"> redis:</span><br><span class="line"> restart: always</span><br><span class="line"> image: redis:alpine</span><br><span class="line"> healthcheck:</span><br><span class="line"> test: [&quot;CMD&quot;, &quot;redis-cli&quot;, &quot;ping&quot;]</span><br><span class="line"> volumes:</span><br><span class="line"> - &quot;./redisdata:/data&quot;</span><br><span class="line"></span><br><span class="line"> worker:</span><br><span class="line"> container_name: worker</span><br><span class="line"> build: .</span><br><span class="line"> image: yukimochi/activity-relay</span><br><span class="line"> working_dir: /var/lib/relay</span><br><span class="line"> restart: always</span><br><span class="line"> init: true</span><br><span class="line"> command: relay worker</span><br><span class="line"> volumes:</span><br><span class="line"> - &quot;./actor.pem:/var/lib/relay/actor.pem&quot;</span><br><span class="line"> - &quot;./config.yml:/var/lib/relay/config.yml&quot;</span><br><span class="line"> depends_on:</span><br><span class="line"> - redis</span><br><span class="line"></span><br><span class="line"> server:</span><br><span class="line"> container_name: relay</span><br><span class="line"> build: .</span><br><span class="line"> image: yukimochi/activity-relay</span><br><span class="line"> working_dir: /var/lib/relay</span><br><span class="line"> restart: always</span><br><span class="line"> init: true</span><br><span class="line"> ports:</span><br><span class="line"> - &quot;8080:8080&quot;</span><br><span class="line"> command: relay server</span><br><span class="line"> volumes:</span><br><span class="line"> - &quot;./actor.pem:/var/lib/relay/actor.pem&quot;</span><br><span class="line"> - &quot;./config.yml:/var/lib/relay/config.yml&quot;</span><br><span class="line"> depends_on:</span><br><span class="line"> - redis</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>Nginx设置</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">upstream relay &#123;</span><br><span class="line"> server 127.0.0.1:8080;</span><br><span class="line"> &#125;</span><br><span class="line"> server &#123;</span><br><span class="line"> server_name relay.example.com;</span><br><span class="line"></span><br><span class="line"> location / &#123;</span><br><span class="line"> root /var/lib/relay;</span><br><span class="line"> try_files $uri $uri/index.html =404;</span><br><span class="line"> &#125;</span><br><span class="line"></span><br><span class="line"> location /inbox &#123;</span><br><span class="line"> rewrite ^/inbox(.*) /$1 break;</span><br><span class="line"> proxy_pass http://relay/;</span><br><span class="line"> proxy_pass_request_headers on;</span><br><span class="line"> proxy_set_header Host $http_host;</span><br><span class="line"> &#125;</span><br><span class="line"></span><br><span class="line"> location /actor &#123;</span><br><span class="line"> rewrite ^/inbox(.*) /$1 break;</span><br><span class="line"> proxy_pass http://relay/;</span><br><span class="line"> proxy_pass_request_headers on;</span><br><span class="line"> proxy_set_header Host $http_host;</span><br><span class="line"> &#125;</span><br><span class="line"></span><br><span class="line"> &#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<div class="post-copyright">
<div class="copyright-item">
<span> 作者: 浪子</span>
</div>
<div class="copyright-item">
<span> 链接: <a href="https://blog.jkjoy.cn/posts/57ea9005.html">https://blog.jkjoy.cn/posts/57ea9005.html</a></span>
</div>
<div class="copyright-item">
<span> 声明: 本博客所有文章除特别声明外,均采用许可协议 <a target="_blank" rel="noopener" href="http://creativecommons.org/licenses/by-nc/4.0/">CC-BY-NC-4.0</a> 转载请注明出处!</span>
</div>
</div>
</div>
<div class="share-reward">
<div class="share">
<div class="social-share" data-sites="wechat,weibo,qq"></div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css">
<script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js"></script>
</div>
<div class="reward">
<div style="padding: 10px 0; margin-left: 20px; width: 90%; text-align: center;">
<div class="reward-content">
<ul id="donateBox" class="list pos-a">
<li id="PayPal"><a href="https://paypal.me/jkjoy" target="_blank" title="贝宝">贝宝</a></li>
<li id="AliPay" title="支付宝"><img data-img="https://blogcdn.loliko.cn/ali.png" onerror=this.onerror=null,this.src="/img/loading.gif"></img></li>
<li id="WeChat" title="微信"><img date-img="https://blogcdn.loliko.cn/wx.png" onerror=this.onerror=null,this.src="/img/loading.gif"></img></li>
</ul>
<div id="QRBox" class="pos-f left-100">
<div id="MainBox"></div>
</div>
</div>
</div>
</div>
</div>
<div class="post_tags">
<i class="fas fa-tag"></i> <a href="/tags/Docker/" class="tag">Docker</a>
</div>
<div class="post-nav">
<div class="post-nav-prev post-nav-item">
<a href="/posts/eb6a87ce.html" >centos在yum时出现Determining fastest mirrors<i class="fa fa-chevron-left"></i></a>
</div>
<div class="post-nav-next post-nav-item">
<a href="/posts/a116570f.html" >NEC M700黑苹果OC0.9.4引导<i class="fa fa-chevron-right"></i></a>
</div>
</div>
<h3><i class="far fa-comment"></i> 评论</h3>
<div id="tcomment"></div>
<script src="/js/twikoo.all.min.js"></script>
<script>
twikoo.init({
envId: 'https://t.jkjoy.cn',
el: '#tcomment',
})
</script>
</article>
<a id="gotop" href="javascript:" title="返回顶部"><i class="fa fa-arrow-up"></i></a>
<div id="bottom-outer">
<div id="bottom-inner">
© 2020 <i class="fa fa-heart" id="heart"></i> 浪子
<br>
Powered by
<a target="_blank" rel="noopener" href="http://hexo.io">hexo</a> | Theme is <a target="_blank" rel="noopener" href="https://github.com/a2396837/hexo-theme-blank/">blank</a>
<div class="icp-info">
<a href="https://beian.miit.gov.cn/" target="_blank"> 鄂ICP备16022970号-16</a>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/layui-src@2.5.5/dist/layui.min.js"></script>
<script src="/js/script.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script>
<script>
window.lazyLoadOptions = {
elements_selector: 'img',
threshold: 0
}
</script>
<script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script>
<script>
var images = $('img').not('.nav-logo img').not('.card img').not($('a>img')).not('.reward-content img')
images.each(function (i, o) {
var lazyloadSrc = $(o).attr('data-src') ? $(o).attr('data-src') : $(o).attr('src')
$(o).wrap(`<a href="${lazyloadSrc}" data-fancybox="group" data-caption="${$(o).attr('alt')}" class="fancybox"></a>`)
})
</script>
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js"></script>
<script>
$().fancybox({
selector: '[data-fancybox]',
loop: true,
transitionEffect: 'slide',
protect: true,
buttons: ['slideShow', 'fullScreen', 'thumbs', 'close']
})
</script>
<script>
jQuery(document).ready(function () {
var QRBox = $('#QRBox');
var MainBox = $('#MainBox');
var AliPayQR = 'https://blogcdn.loliko.cn/ali.png';
var WeChanQR = 'https://blogcdn.loliko.cn/wx.png';
function showQR(QR) {
if (QR) {
MainBox.css('background-image', 'url(' + QR + ')');
}
$('#donateBox').addClass('blur');
QRBox.fadeIn(300, function (argument) {
MainBox.addClass('showQR');
});
}
$('#donateBox>li').click(function (event) {
var thisID = $(this).attr('id');
if (thisID === 'AliPay') {
showQR(AliPayQR);
} else if (thisID === 'WeChat') {
showQR(WeChanQR);
}
});
MainBox.click(function (event) {
MainBox.removeClass('showQR').addClass('hideQR');
setTimeout(function (a) {
QRBox.fadeOut(300, function (argument) {
MainBox.removeClass('hideQR');
});
$('#DonateText,#donateBox,#github').removeClass('blur');
}, 600);
});
});
</script>
<script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module" defer></script>
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.4/dist/clipboard.min.js"></script>
<script>
!function (e, t, a) {
var initCopyCode = function(){
var copyHtml = '';
copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
copyHtml += ' <i class="fa fa-clipboard"></i><span>复制</span>';
copyHtml += '</button>';
$(".highlight .code pre").before(copyHtml);
new ClipboardJS('.btn-copy', {
target: function(trigger) {
return trigger.nextElementSibling;
}
});
}
initCopyCode();
}(window, document);
</script>
<script>
var btntop = $('#gotop');
btntop.on('click', function (e) {
e.preventDefault();
$('html, body').animate({ scrollTop: 0 }, '300');
});
var $table = $('.content table').not($('figure.highlight > table'))
$table.each(function () {
$(this).wrap('<div class="table-wrap"></div>')
})
</script>
</html>