Site updated: 2022-11-08 12:40:58
This commit is contained in:
1 parent
53430dc3e3
commit
f5b51694a7
106 files changed
+315
-220
No files matched your search
@@ -11,7 +11,7 @@
|
||||
"url": "https://blog.jingxiyuan.cn/2022/11/08/Nginx%E9%85%8D%E7%BD%AE-%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86/",
|
||||
"title": "Nginx配置-反向代理",
|
||||
"date_published": "2022-11-08T02:05:00.000Z",
|
||||
"content_html": "<h4 id=\"引言\"><a class=\"anchor\" href=\"#引言\">#</a> 引言</h4>\n<ul>\n<li>所有配置方法和介绍均来至于网络搜索汇总,主要用于方便后期巩固学习。</li>\n</ul>\n<h4 id=\"何为反向代理\"><a class=\"anchor\" href=\"#何为反向代理\">#</a> 何为反向代理</h4>\n<ul>\n<li>在介绍反向代理之前,先来了解一下正向代理。</li>\n</ul>\n<p>__正向代理:__如果把局域网外的 Internet 想象成一个巨大的资源库,则局域网中的客户端要访问 Internet,则需要通过代理服务器来访问,这种代理服务就称为正向代理,下面是正向代理的原理图。<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/11/08/991a203be1ec82b36e1f326376617d40.png\" alt=\"991a203be1ec82b36e1f326376617d40.png\" /><br />\n__反向代理:__看下面原理图,就一目了然。其实客户端对代理是无感知的,因为客户端不需要任何配置就可以访问,我们只需要将请求发送到反向代理服务器,由反向代理服务器去选择目标服务器获取数据后,在返回给客户端,此时反向代理服务器和目标服务器对外就是一个服务器,暴露的是代理服务器地址,隐藏了真实服务器 IP 地址。<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/11/08/1c87e386a0ce624a3949bda443cf346d.png\" alt=\"1c87e386a0ce624a3949bda443cf346d.png\" /></p>\n<blockquote>\n<p>正向代理和反向代理的区别,一句话就是:如果我们客户端自己用,就是正向代理。如果是在服务器用,用户无感知,就是反向代理。</p>\n</blockquote>\n<h4 id=\"nginx配置文件\"><a class=\"anchor\" href=\"#nginx配置文件\">#</a> Nginx 配置文件</h4>\n<ul>\n<li>\n<p>在学习 Nginx 之前,要熟知它的配置文件,毕竟,下面需要做的所有配置(反向代理、负载均衡、动静分离等),都是基于它的配置文件。</p>\n</li>\n<li>\n<p>Nginx 默认的配置文件是在安装目录下的 conf 目录下,后续对 Nginx 的使用基本上都是对此配置文件进行相应的修改。完整的配置文件,可以看一下文章最后。修改过 nginx.conf 配置文件,记得要重启 Nginx 服务(☆☆☆☆☆)</p>\n</li>\n<li>\n<p>配置文件中有很多 #号,该符号表示注释内容,去掉所有以 #开头的段落,精简之后的配置文件内容如下(PS:其实注释掉的地方,都是一些功能的使用代码,需要用到的时候,取消注释即可):</p>\n</li>\n</ul>\n<figure class=\"highlight xml\"><figcaption data-lang=\"XML\"></figcaption><table><tr><td data-num=\"1\"></td><td><pre># 主进程叫master,负责管理子进程,子进程叫worker</pre></td></tr><tr><td data-num=\"2\"></td><td><pre># worker_processes配置项表示开启几个业务进程,一般和cpu核数有关</pre></td></tr><tr><td data-num=\"3\"></td><td><pre>worker_processes 1;</pre></td></tr><tr><td data-num=\"4\"></td><td><pre></pre></td></tr><tr><td data-num=\"5\"></td><td><pre>events {</pre></td></tr><tr><td data-num=\"6\"></td><td><pre> worker_connections 1024;</pre></td></tr><tr><td data-num=\"7\"></td><td><pre>}</pre></td></tr><tr><td data-num=\"8\"></td><td><pre></pre></td></tr><tr><td data-num=\"9\"></td><td><pre>http {</pre></td></tr><tr><td data-num=\"10\"></td><td><pre>\t# include表示可以引入其他文件,此处表示引入http mime类型</pre></td></tr><tr><td data-num=\"11\"></td><td><pre> include mime.types;</pre></td></tr><tr><td data-num=\"12\"></td><td><pre> default_type application/octet-stream;</pre></td></tr><tr><td data-num=\"13\"></td><td><pre> sendfile on;</pre></td></tr><tr><td data-num=\"14\"></td><td><pre> keepalive_timeout 65;</pre></td></tr><tr><td data-num=\"15\"></td><td><pre></pre></td></tr><tr><td data-num=\"16\"></td><td><pre>\t# 虚拟主机,可以配置多个</pre></td></tr><tr><td data-num=\"17\"></td><td><pre> server {</pre></td></tr><tr><td data-num=\"18\"></td><td><pre> listen 80;</pre></td></tr><tr><td data-num=\"19\"></td><td><pre> server_name localhost;</pre></td></tr><tr><td data-num=\"20\"></td><td><pre></pre></td></tr><tr><td data-num=\"21\"></td><td><pre> location / {</pre></td></tr><tr><td data-num=\"22\"></td><td><pre> \t# 路径匹配之后,哪个目录下去匹配相应的网页,html是相对路径</pre></td></tr><tr><td data-num=\"23\"></td><td><pre> root html;</pre></td></tr><tr><td data-num=\"24\"></td><td><pre> index index.html index.htm;</pre></td></tr><tr><td data-num=\"25\"></td><td><pre> }</pre></td></tr><tr><td data-num=\"26\"></td><td><pre></pre></td></tr><tr><td data-num=\"27\"></td><td><pre> error_page 500 502 503 504 /50x.html;</pre></td></tr><tr><td data-num=\"28\"></td><td><pre> location = /50x.html {</pre></td></tr><tr><td data-num=Line truncated
|
||||
"content_html": "<h4 id=\"引言\"><a class=\"anchor\" href=\"#引言\">#</a> 引言</h4>\n<ul>\n<li>所有配置方法和介绍均来至于网络搜索汇总,主要用于方便后期巩固学习。</li>\n</ul>\n<h4 id=\"何为反向代理\"><a class=\"anchor\" href=\"#何为反向代理\">#</a> 何为反向代理</h4>\n<ul>\n<li>在介绍反向代理之前,先来了解一下正向代理。</li>\n</ul>\n<p>__正向代理:__如果把局域网外的 Internet 想象成一个巨大的资源库,则局域网中的客户端要访问 Internet,则需要通过代理服务器来访问,这种代理服务就称为正向代理,下面是正向代理的原理图。<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/11/08/991a203be1ec82b36e1f326376617d40.png\" alt=\"991a203be1ec82b36e1f326376617d40.png\" /><br />\n__反向代理:__看下面原理图,就一目了然。其实客户端对代理是无感知的,因为客户端不需要任何配置就可以访问,我们只需要将请求发送到反向代理服务器,由反向代理服务器去选择目标服务器获取数据后,在返回给客户端,此时反向代理服务器和目标服务器对外就是一个服务器,暴露的是代理服务器地址,隐藏了真实服务器 IP 地址。<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/11/08/1c87e386a0ce624a3949bda443cf346d.png\" alt=\"1c87e386a0ce624a3949bda443cf346d.png\" /></p>\n<blockquote>\n<p>正向代理和反向代理的区别,一句话就是:如果我们客户端自己用,就是正向代理。如果是在服务器用,用户无感知,就是反向代理。</p>\n</blockquote>\n<h4 id=\"nginx配置文件\"><a class=\"anchor\" href=\"#nginx配置文件\">#</a> Nginx 配置文件</h4>\n<ul>\n<li>\n<p>在学习 Nginx 之前,要熟知它的配置文件,毕竟,下面需要做的所有配置(反向代理、负载均衡、动静分离等),都是基于它的配置文件。</p>\n</li>\n<li>\n<p>Nginx 默认的配置文件是在安装目录下的 conf 目录下,后续对 Nginx 的使用基本上都是对此配置文件进行相应的修改。完整的配置文件,可以看一下文章最后。修改过 nginx.conf 配置文件,记得要重启 Nginx 服务(☆☆☆☆☆)</p>\n</li>\n<li>\n<p>配置文件中有很多 #号,该符号表示注释内容,去掉所有以 #开头的段落,精简之后的配置文件内容如下(PS:其实注释掉的地方,都是一些功能的使用代码,需要用到的时候,取消注释即可):</p>\n</li>\n</ul>\n<pre><code class=\"language-yaml\"># 主进程叫master,负责管理子进程,子进程叫worker\n# worker_processes配置项表示开启几个业务进程,一般和cpu核数有关\nworker_processes 1;\n\nevents {\n worker_connections 1024;\n}\n\nhttp {\n\t# include表示可以引入其他文件,此处表示引入http mime类型\n include mime.types;\n default_type application/octet-stream;\n sendfile on;\n keepalive_timeout 65;\n\n\t# 虚拟主机,可以配置多个\n server {\n listen 80;\n server_name localhost;\n\n location / {\n \t# 路径匹配之后,哪个目录下去匹配相应的网页,html是相对路径\n root html;\n index index.html index.htm;\n }\n\n error_page 500 502 503 504 /50x.html;\n location = /50x.html {\n root html;\n }\n\t}\n}\n</code></pre>\n<p>去掉注释信息后,可以将 nginx.conf 配置文件分为三部分:</p>\n<ol>\n<li>全局块</li>\n</ol>\n<pre><code class=\"language-yaml\">worker_processes 1;\n</code></pre>\n<p>从配置文件开始到 events 块之间的内容,主要会设置一些影响 Nginx 服务器整体运行的配置指令,主要包括:配置运行 Nginx 服务器的用户(组)、允许生成的 worker process 数,进程 PID 存放路径、日志存放路径和类型以及配置文件的引入等。</p>\n<p>上面这行 worker_processes 配置,是 Nginx 服务器并发处理服务的关键配置,该值越大,可以支持的并发处理量也越多,但是会受到硬件、软件等设备的约束。</p>\n<ol start=\"2\">\n<li>events 块</li>\n</ol>\n<pre><code class=\"language-yaml\">events {\n\tworker_connections 1024;\n}\n</code></pre>\n<p>events 块涉及的指令主要影响 Nginx 服务器与用户的网络连接,常用的设置包括:是否开启对多 work process 下的网络连接进行序列化,是否允许同时接收多个网络连接,选取哪种事件驱动模型来处理连接请求,每个 work process 可以同时支持的最大连接数等</p>\n<p>上述例子就表示每个 work process 支持的最大连接数为 1024。这部分的配置对 Nginx 的性能影响较大,在实际中应该灵活配置。</p>\n<ol start=\"3\">\n<li>http 块</li>\n</ol>\n<pre><code clLine truncated
|
||||
"tags": [
|
||||
"Linux",
|
||||
"服务",
|
||||
@@ -25,7 +25,7 @@
|
||||
"url": "https://blog.jingxiyuan.cn/2022/11/04/%E8%AE%B0%E4%B8%80%E6%AC%A1Vue%E9%A1%B9%E7%9B%AE%E7%9A%84%E9%83%A8%E7%BD%B2/",
|
||||
"title": "记一次Vue项目的部署",
|
||||
"date_published": "2022-11-04T07:21:00.000Z",
|
||||
"content_html": "<h4 id=\"描述\"><a class=\"anchor\" href=\"#描述\">#</a> 描述</h4>\n<ul>\n<li>今天需要把一个 web 项目部署到 ubuntu 服务器上,结果直接使用 apt install nodejs 安装的 nodejs 版本过低,导致编译失败。最后通过查看官网文档获取到了 ubuntu 最新 nodejs 的安装命令。</li>\n</ul>\n<h4 id=\"过程\"><a class=\"anchor\" href=\"#过程\">#</a> 过程</h4>\n<ul>\n<li>卸载旧的 nodejs(此命令会卸载掉相关依赖包)</li>\n</ul>\n<pre><code class=\"language-bash\">sudo apt autoremove --purge nodejs\n</code></pre>\n<ul>\n<li>安装 NodeJS</li>\n</ul>\n<pre><code class=\"language-bash\">curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - && sudo apt-get install -y nodejs\n</code></pre>\n<ul>\n<li>安装 yarn</li>\n</ul>\n<pre><code class=\"language-bash\">curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null\n\necho "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list\n\nsudo apt-get update && sudo apt-get install yarn\n</code></pre>\n<ul>\n<li>初始化 (到项目根目录执行)</li>\n</ul>\n<pre><code class=\"language-bash\">yarn install\n</code></pre>\n<ul>\n<li>编译(到项目根目录执行,完成后会生成 dist 目录)</li>\n</ul>\n<pre><code class=\"language-bash\">yarn build\n</code></pre>\n<ul>\n<li>安装 nginx</li>\n</ul>\n<pre><code class=\"language-bash\">apt install nginx\n</code></pre>\n<ul>\n<li>配置 nginx (编译 /etc/nginx/sites-available/default)</li>\n</ul>\n<pre><code class=\"language-conf\">server {\n listen 80 default_server;\n listen [::]:80 default_server;\n\n # SSL configuration\n #\n # listen 443 ssl default_server;\n # listen [::]:443 ssl default_server;\n #\n # Note: You should disable gzip for SSL traffic.\n # See: https://bugs.debian.org/773332\n #\n # Read up on ssl_ciphers to ensure a secure configuration.\n # See: https://bugs.debian.org/765782\n #\n # Self signed certs generated by the ssl-cert package\n # Don't use them in a production server!\n #\n # include snippets/snakeoil.conf;\n\n root /var/www/html;\n\n # Add index.php to the list if you are using PHP\n index index.html index.htm index.nginx-debian.html;\n\n server_name _;\n\n location /api {\n proxy_pass http://localhost:8080;\n }\n\n location / {\n # First attempt to serve request as file, then\n # as directory, then fall back to displaying a 404.\n #try_files $uri $uri/ =404;\n alias /opt/codes/dayu-tools-arbitrage-web/dist/;\n try_files $uri $uri/ @router;\n index index.html index.htm;\n }\n\n location @router {\n rewrite ^.*$ /index.html last;\n }\n}\n\n</code></pre>\n<h4 id=\"其它\"><a class=\"anchor\" href=\"#其它\">#</a> 其它</h4>\n<ul>\n<li>重新编译前需要先删除 dist 目录</li>\n</ul>\n<pre><code class=\"language-bash\">rm dist -fr\n\nyarn build\n</code></pre>\n",
|
||||
"content_html": "<h4 id=\"描述\"><a class=\"anchor\" href=\"#描述\">#</a> 描述</h4>\n<ul>\n<li>今天需要把一个 web 项目部署到 ubuntu 服务器上,结果直接使用 apt install nodejs 安装的 nodejs 版本过低,导致编译失败。最后通过查看官网文档获取到了 ubuntu 最新 nodejs 的安装命令。</li>\n</ul>\n<h4 id=\"过程\"><a class=\"anchor\" href=\"#过程\">#</a> 过程</h4>\n<ul>\n<li>卸载旧的 nodejs(此命令会卸载掉相关依赖包)</li>\n</ul>\n<pre><code class=\"language-bash\">sudo apt autoremove --purge nodejs\n</code></pre>\n<ul>\n<li>安装 NodeJS</li>\n</ul>\n<pre><code class=\"language-bash\">curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - && sudo apt-get install -y nodejs\n</code></pre>\n<ul>\n<li>安装 yarn</li>\n</ul>\n<pre><code class=\"language-bash\">curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null\n\necho "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list\n\nsudo apt-get update && sudo apt-get install yarn\n</code></pre>\n<ul>\n<li>初始化 (到项目根目录执行)</li>\n</ul>\n<pre><code class=\"language-bash\">yarn install\n</code></pre>\n<ul>\n<li>编译(到项目根目录执行,完成后会生成 dist 目录)</li>\n</ul>\n<pre><code class=\"language-bash\">yarn build\n</code></pre>\n<ul>\n<li>安装 nginx</li>\n</ul>\n<pre><code class=\"language-bash\">apt install nginx\n</code></pre>\n<ul>\n<li>配置 nginx (编译 /etc/nginx/sites-available/default)</li>\n</ul>\n<pre><code class=\"language-yaml\">server {\n listen 80 default_server;\n listen [::]:80 default_server;\n\n # SSL configuration\n #\n # listen 443 ssl default_server;\n # listen [::]:443 ssl default_server;\n #\n # Note: You should disable gzip for SSL traffic.\n # See: https://bugs.debian.org/773332\n #\n # Read up on ssl_ciphers to ensure a secure configuration.\n # See: https://bugs.debian.org/765782\n #\n # Self signed certs generated by the ssl-cert package\n # Don't use them in a production server!\n #\n # include snippets/snakeoil.conf;\n\n root /var/www/html;\n\n # Add index.php to the list if you are using PHP\n index index.html index.htm index.nginx-debian.html;\n\n server_name _;\n\n location /api {\n proxy_pass http://localhost:8080;\n }\n\n location / {\n # First attempt to serve request as file, then\n # as directory, then fall back to displaying a 404.\n #try_files $uri $uri/ =404;\n alias /opt/codes/dayu-tools-arbitrage-web/dist/;\n try_files $uri $uri/ @router;\n index index.html index.htm;\n }\n\n location @router {\n rewrite ^.*$ /index.html last;\n }\n}\n\n</code></pre>\n<h4 id=\"其它\"><a class=\"anchor\" href=\"#其它\">#</a> 其它</h4>\n<ul>\n<li>重新编译前需要先删除 dist 目录</li>\n</ul>\n<pre><code class=\"language-bash\">rm dist -fr\n\nyarn build\n</code></pre>\n",
|
||||
"tags": [
|
||||
"Linux",
|
||||
"项目部署",
|
||||
@@ -90,7 +90,7 @@
|
||||
"url": "https://blog.jingxiyuan.cn/2022/10/27/%E6%9E%81%E7%A9%BA%E9%97%B4web%E7%AB%AFhttps%E7%9B%B4%E8%BF%9Enginx%E9%85%8D%E7%BD%AE/",
|
||||
"title": "极空间web端https直连nginx配置",
|
||||
"date_published": "2022-10-27T05:34:00.000Z",
|
||||
"content_html": "<h4 id=\"介绍\"><a class=\"anchor\" href=\"#介绍\">#</a> 介绍</h4>\n<ul>\n<li>ip 直连一般都映射了 5055, 但是直接访问 5055 极空间只提供了 http 协议,如果希望使用 https 协议则必须使用其它端口进行访问。以下方案采用 nginx 反向代理实现,端口使用 10000 举例。<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/27/2022-10-27-14-39-25.jpg\" alt=\"\" /></li>\n</ul>\n<h4 id=\"配置\"><a class=\"anchor\" href=\"#配置\">#</a> 配置</h4>\n<ol>\n<li>需要先把 10000 端口在路由器上做好映射。</li>\n<li>证书生成好并放置到 nginx 上。(证书生成方法不做介绍请自行百度)</li>\n<li>http 跳转 https 配置</li>\n</ol>\n<pre><code class=\"language-conf\">server {\n\t\tif ($scheme = http) {\n\t\t\trewrite ^(.*)$ https://$host$1 permanent;\n\t\t}\n}\n</code></pre>\n<ol start=\"4\">\n<li>web 端口监听配置</li>\n</ol>\n<pre><code class=\"language-conf\">#极空间-web\nserver {\n\tlisten 10000 ssl http2; #ipv4\n\tlisten [::]:10000 ssl http2; #ipv6\n\tserver_name xxx.xxx.com; #填写自己的域名,主域名或者子域名\n\n\t#include /etc/nginx/conf.d/ssl/ssl_common.conf;\n\tssl_certificate_key /etc/nginx/conf.d/ssl/xxx.key; #加密证书\n\tssl_certificate /etc/nginx/conf.d/ssl/xxx.pem; #加密证书\n\tssl_session_timeout 1d;\n\tssl_session_cache shared:MozSSL:10m;\n\tssl_session_tickets off;\n\tssl_protocols TLSv1.2 TLSv1.3;\n\tssl_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;\n\tssl_prefer_server_ciphers on;\n\n #开启OCSP stapling\n\tssl_stapling on;\n\tssl_stapling_verify on;\n\n\tclient_max_body_size 128M;\n\n\tadd_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";\n\n\tproxy_send_timeout 180s; #设置发送超时时间\n proxy_read_timeout 180s; #设置读取超时时间\n\n\t# Prevent Information leaks\n\tproxy_hide_header X-Powered-By;\n\tproxy_hide_header Server;\n\tproxy_hide_header X-AspNetMvc-Version;\n\tproxy_hide_header X-AspNet-Version;\n\n\t# http security headers\n\tadd_header X-Content-Type-Options nosniff;\n\tadd_header Pragma no-cache;\n\tadd_header Cache-Control no-store;\n\tadd_header X-XSS-Protection "1; mode=block";\n\tadd_header Referrer-Policy origin-when-cross-origin;\n\tadd_header X-Permitted-Cross-Domain-Policies none;\n add_header X-Frame-Options SAMEORIGIN; #允许同域嵌套\n\n\t# Add Security cookie flags\n\tproxy_cookie_path ~(.*) "$1; SameSite=strict; secure; httponly";\n\n\t# Path to the root of your installation\n\tlocation / {\n\t\tproxy_intercept_errors on;\n\t\tproxy_max_temp_file_size 0;\n\t\tproxy_set_header Host $host;\n\t\tproxy_set_header X-Real-IP $remote_addr;\n\t\tproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n\t\tproxy_set_header X-Forwarded-Proto $scheme;\n \n\t\tproxy_pass http://极空间内网ip:5055; #这里设置你自己要跳转的局域网应用;\n\t\tproxy_redirect http://域名:5055/home https://域名:10000/home; #极空间在登陆后会跳转到http协议的5055端口,所以要在此替换为https协议的10000端口\n\t}\n\n\terror_page 500 502 503 504 /500.html;\n\terror_page 400 404 /500.html;\n\tlocation = /500.html {\n\t\troot /usr/share/nginx/html/; #错误html\n\t}\n}\n</code></pre>\n<h4 id=\"问题\"><a class=\"anchor\" href=\"#问题\">#</a> 问题</h4>\n<ul>\n<li>需要开启允许嵌套否则登陆后所有应用都是拒绝访问</li>\n<li>需要配置 proxy_redirect 替换响应 url,否则会跳转到默认 http 协议的 5055 端口</li>\n<li>如果配置 proxy_redirect 后无效可能需要清除浏览器缓存(F12 - 网络 - 右键点击 url 区域 - 清除浏览器缓存)</li>\n</ul>\n",
|
||||
"content_html": "<h4 id=\"介绍\"><a class=\"anchor\" href=\"#介绍\">#</a> 介绍</h4>\n<ul>\n<li>ip 直连一般都映射了 5055, 但是直接访问 5055 极空间只提供了 http 协议,如果希望使用 https 协议则必须使用其它端口进行访问。以下方案采用 nginx 反向代理实现,端口使用 10000 举例。<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/27/2022-10-27-14-39-25.jpg\" alt=\"\" /></li>\n</ul>\n<h4 id=\"配置\"><a class=\"anchor\" href=\"#配置\">#</a> 配置</h4>\n<ol>\n<li>需要先把 10000 端口在路由器上做好映射。</li>\n<li>证书生成好并放置到 nginx 上。(证书生成方法不做介绍请自行百度)</li>\n<li>http 跳转 https 配置</li>\n</ol>\n<pre><code class=\"language-yaml\">server {\n\t\tif ($scheme = http) {\n\t\t\trewrite ^(.*)$ https://$host$1 permanent;\n\t\t}\n}\n</code></pre>\n<ol start=\"4\">\n<li>web 端口监听配置</li>\n</ol>\n<pre><code class=\"language-yaml\">#极空间-web\nserver {\n\tlisten 10000 ssl http2; #ipv4\n\tlisten [::]:10000 ssl http2; #ipv6\n\tserver_name xxx.xxx.com; #填写自己的域名,主域名或者子域名\n\n\t#include /etc/nginx/conf.d/ssl/ssl_common.conf;\n\tssl_certificate_key /etc/nginx/conf.d/ssl/xxx.key; #加密证书\n\tssl_certificate /etc/nginx/conf.d/ssl/xxx.pem; #加密证书\n\tssl_session_timeout 1d;\n\tssl_session_cache shared:MozSSL:10m;\n\tssl_session_tickets off;\n\tssl_protocols TLSv1.2 TLSv1.3;\n\tssl_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;\n\tssl_prefer_server_ciphers on;\n\n #开启OCSP stapling\n\tssl_stapling on;\n\tssl_stapling_verify on;\n\n\tclient_max_body_size 128M;\n\n\tadd_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";\n\n\tproxy_send_timeout 180s; #设置发送超时时间\n proxy_read_timeout 180s; #设置读取超时时间\n\n\t# Prevent Information leaks\n\tproxy_hide_header X-Powered-By;\n\tproxy_hide_header Server;\n\tproxy_hide_header X-AspNetMvc-Version;\n\tproxy_hide_header X-AspNet-Version;\n\n\t# http security headers\n\tadd_header X-Content-Type-Options nosniff;\n\tadd_header Pragma no-cache;\n\tadd_header Cache-Control no-store;\n\tadd_header X-XSS-Protection "1; mode=block";\n\tadd_header Referrer-Policy origin-when-cross-origin;\n\tadd_header X-Permitted-Cross-Domain-Policies none;\n add_header X-Frame-Options SAMEORIGIN; #允许同域嵌套\n\n\t# Add Security cookie flags\n\tproxy_cookie_path ~(.*) "$1; SameSite=strict; secure; httponly";\n\n\t# Path to the root of your installation\n\tlocation / {\n\t\tproxy_intercept_errors on;\n\t\tproxy_max_temp_file_size 0;\n\t\tproxy_set_header Host $host;\n\t\tproxy_set_header X-Real-IP $remote_addr;\n\t\tproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n\t\tproxy_set_header X-Forwarded-Proto $scheme;\n \n\t\tproxy_pass http://极空间内网ip:5055; #这里设置你自己要跳转的局域网应用;\n\t\tproxy_redirect http://域名:5055/home https://域名:10000/home; #极空间在登陆后会跳转到http协议的5055端口,所以要在此替换为https协议的10000端口\n\t}\n\n\terror_page 500 502 503 504 /500.html;\n\terror_page 400 404 /500.html;\n\tlocation = /500.html {\n\t\troot /usr/share/nginx/html/; #错误html\n\t}\n}\n</code></pre>\n<h4 id=\"问题\"><a class=\"anchor\" href=\"#问题\">#</a> 问题</h4>\n<ul>\n<li>需要开启允许嵌套否则登陆后所有应用都是拒绝访问</li>\n<li>需要配置 proxy_redirect 替换响应 url,否则会跳转到默认 http 协议的 5055 端口</li>\n<li>如果配置 proxy_redirect 后无效可能需要清除浏览器缓存(F12 - 网络 - 右键点击 url 区域 - 清除浏览器缓存)</li>\n</ul>\n",
|
||||
"tags": [
|
||||
"极空间",
|
||||
"nginx",
|
||||
@@ -104,7 +104,7 @@
|
||||
"url": "https://blog.jingxiyuan.cn/2022/10/22/%E6%9E%81%E7%A9%BA%E9%97%B4Docker%E7%89%88%E9%9D%92%E9%BE%99%E9%9D%A2%E6%9D%BF%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AE/",
|
||||
"title": "极空间Docker版青龙面板安装与配置",
|
||||
"date_published": "2022-10-22T02:44:00.000Z",
|
||||
"content_html": "<h4 id=\"介绍\"><a class=\"anchor\" href=\"#介绍\">#</a> 介绍</h4>\n<ul>\n<li>青龙面板是一个支持 python3、javascript、shell、typescript 的定时任务管理面板。它支持在线管理脚本、环境变量、配置文件,支持在线查看日志及支持多种方式的消息通知。</li>\n</ul>\n<h4 id=\"安装\"><a class=\"anchor\" href=\"#安装\">#</a> 安装</h4>\n<ul>\n<li>本文使用的是<span class=\"exturl\" data-url=\"aHR0cHM6Ly9odWIuZG9ja2VyLmNvbS9yL3doeW91ci9xaW5nbG9uZw==\"> whyour/qinglong</span> 的镜像。</li>\n<li>路径映射(由于青龙面板有 nodejs 环境,所以我把 hexo 博客的编译也放置在上面,再把 nginx 的 html 映射过来,这样就可以直接编译发布了。)<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/24/2022-10-24-19-29-06.jpg\" alt=\"\" /></li>\n</ul>\n<pre><code class=\"language-conf\">#青龙面板装载路径\n/ql/data\n#博客装载路径(如果你不部署hexo博客可以不用配置)\n/root/.ssh #ssh证书文件(如果你不用把hexo推送到git上可以不用配置)\n/blog #hexo博客编译目录\n/blog/nginx_blog #nginx上放置博客的目录(例如:/Docker/nginx/html/blog)\n</code></pre>\n<ul>\n<li>端口<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/22/2022-10-22-11-02-195ea093b249c53244.jpg\" alt=\"\" /><br />\n <code>4000端口是hexo-admin使用的,如果你不用可以不配置</code></li>\n<li>环境<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/22/2022-10-22-11-02-19a0822966d88a012e.jpg\" alt=\"\" /></li>\n<li>登录<br />\n地址:<span class=\"exturl\" data-url=\"aHR0cDovL3huLS1JUC1odThkeTcwZTRtNWE6NTcwMA==\">http:// 极空间 IP:5700</span><br />\n 默认账号:admin<br />\n 默认密码:admin</li>\n</ul>\n<h4 id=\"配置\"><a class=\"anchor\" href=\"#配置\">#</a> 配置</h4>\n<ul>\n<li>我主要用青龙面板跑京东的脚本,所以也只介绍相关的配置方法</li>\n<li>定时任务 (我使用的是 KingRan/KR 的集合库,以下是拉取命令)<br />\n <code>ql repo https://github.com/KingRan/KR.git "jd_|jx_|jdCookie" "activity|backUp|wskey" "^jd[^_]|USER|utils|function|sign|sendNotify|ql|JDJR"</code></li>\n<li>定时规则(我是每 3 小时拉取一次,不要拉取太频繁否则可能被封)<br />\n <code>0 */3 * * *</code></li>\n<li>环境变量</li>\n</ul>\n<pre><code class=\"language-conf\">名称:JD_COOKIE\n值:web京东登陆后按F12在网络tab页中的请求内查找cookie,然后复制pt_key=到pt_pin=等\n</code></pre>\n<ul>\n<li>配置文件 (主要修改和添加以下配置)</li>\n</ul>\n<pre><code class=\"language-conf\">repo命令拉取脚本时需要拉取的文件后缀,直接写文件后缀名即可\nRepoFileExtensions="js py ts"\n钉钉(消息推送)\nexport DD_BOT_TOKEN=\nexport DD_BOT_SECRET=\n##开卡\nexport guaopencard_All="true"\nexport guaopencard_addSku_All="true"\nexport guaopencardRun_All="true"\nexport guaopencard_draw="true"\nexport JD_TRY="true"\nexport exjxbeans="true"\nexport DY_OPENALL="true"\n#抽奖\nexport opencard_draw=3\n#开启脚本依赖文件缺失修复\nexport ec_fix_dep="true" \n#开启脚本依赖文件更新\nexport ec_re_dep="true" \n#清空购物车\nexport JD_CART_REMOVE="true"\nexport JD_CART="true"\n#去掉多余的双十一红包脚本\nexport FLCODE=''\n#加购物车抽奖\nexport RUN_CAR=true\n#停用小额免密支付\nexport JD_PAY_CONTRACT=true\n</code></pre>\n<ul>\n<li>依赖管理</li>\n</ul>\n<pre><code class=\"language-conf\">#nodejs依赖\ncrypto-js\t\nprettytable\t\ndotenv\t\njsdom\t\ndate-fns\t\ntough-cookie\t\ntslib\t\nws@7.4.3\t\nts-md5\t\njsdom -g\t\njieba\t\nfs\t\nform-data\t\njson5\t\nglobal-agent\t\npng-js\t\n@types/node\t\nrequire\t\ntypescript\t\njs-base64\t\naxios\n#pythone依赖\nrequests\t\ncanvas\t\nping3\t\njieba\t\naiohttp\t\nPyExecJS\n#Linux依赖\nbizCode\nbizMsg\nlxml\n</code></pre>\n<h4 id=\"其它\"><a class=\"anchor\" href=\"#其它\">#</a> 其它</h4>\n<pre><code class=\"language-bash\">#配置国内源\npip config --global set global.index-url https://mirrors.aliyun.com/pypi/simple/\npip config --global set install.trusted-host https://mirrors.aliyun.com\n\n#升级pip\npip install --upgrade pip\n\n#更新青龙\nql update\n\n#已知要安装的依赖(不安装部分脚本任务会失败)\npnpm install ds\n\n#一键安装所有依赖(基于Faker一键脚本安装的青龙\n可通过执行/ql/data/scripts下的QLDependency.sh脚本安装,如脚本已经更新则通过下面命令执行\ncurl -fsSL https://git.metauniverse-cn.com/https://raw.githubusercontent.com/shufflewzc/QLDependency/main/Shell/QLOneKeyDependency.sh | sh\n\n#一般出现这种错误:(缺依赖)\nError: Cannot find module 'xx'\n执行pnpm inLine truncated
|
||||
"content_html": "<h4 id=\"介绍\"><a class=\"anchor\" href=\"#介绍\">#</a> 介绍</h4>\n<ul>\n<li>青龙面板是一个支持 python3、javascript、shell、typescript 的定时任务管理面板。它支持在线管理脚本、环境变量、配置文件,支持在线查看日志及支持多种方式的消息通知。</li>\n</ul>\n<h4 id=\"安装\"><a class=\"anchor\" href=\"#安装\">#</a> 安装</h4>\n<ul>\n<li>本文使用的是<span class=\"exturl\" data-url=\"aHR0cHM6Ly9odWIuZG9ja2VyLmNvbS9yL3doeW91ci9xaW5nbG9uZw==\"> whyour/qinglong</span> 的镜像。</li>\n<li>路径映射(由于青龙面板有 nodejs 环境,所以我把 hexo 博客的编译也放置在上面,再把 nginx 的 html 映射过来,这样就可以直接编译发布了。)<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/24/2022-10-24-19-29-06.jpg\" alt=\"\" /></li>\n</ul>\n<pre><code class=\"language-yaml\">#青龙面板装载路径\n/ql/data\n#博客装载路径(如果你不部署hexo博客可以不用配置)\n/root/.ssh #ssh证书文件(如果你不用把hexo推送到git上可以不用配置)\n/blog #hexo博客编译目录\n/blog/nginx_blog #nginx上放置博客的目录(例如:/Docker/nginx/html/blog)\n</code></pre>\n<ul>\n<li>端口<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/22/2022-10-22-11-02-195ea093b249c53244.jpg\" alt=\"\" /><br />\n <code>4000端口是hexo-admin使用的,如果你不用可以不配置</code></li>\n<li>环境<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/22/2022-10-22-11-02-19a0822966d88a012e.jpg\" alt=\"\" /></li>\n<li>登录<br />\n地址:<span class=\"exturl\" data-url=\"aHR0cDovL3huLS1JUC1odThkeTcwZTRtNWE6NTcwMA==\">http:// 极空间 IP:5700</span><br />\n 默认账号:admin<br />\n 默认密码:admin</li>\n</ul>\n<h4 id=\"配置\"><a class=\"anchor\" href=\"#配置\">#</a> 配置</h4>\n<ul>\n<li>我主要用青龙面板跑京东的脚本,所以也只介绍相关的配置方法</li>\n<li>定时任务 (我使用的是 KingRan/KR 的集合库,以下是拉取命令)<br />\n <code>ql repo https://github.com/KingRan/KR.git "jd_|jx_|jdCookie" "activity|backUp|wskey" "^jd[^_]|USER|utils|function|sign|sendNotify|ql|JDJR"</code></li>\n<li>定时规则(我是每 3 小时拉取一次,不要拉取太频繁否则可能被封)<br />\n <code>0 */3 * * *</code></li>\n<li>环境变量</li>\n</ul>\n<pre><code class=\"language-yaml\">名称:JD_COOKIE\n值:web京东登陆后按F12在网络tab页中的请求内查找cookie,然后复制pt_key=到pt_pin=等\n</code></pre>\n<ul>\n<li>配置文件 (主要修改和添加以下配置)</li>\n</ul>\n<pre><code class=\"language-yaml\">repo命令拉取脚本时需要拉取的文件后缀,直接写文件后缀名即可\nRepoFileExtensions="js py ts"\n钉钉(消息推送)\nexport DD_BOT_TOKEN=\nexport DD_BOT_SECRET=\n##开卡\nexport guaopencard_All="true"\nexport guaopencard_addSku_All="true"\nexport guaopencardRun_All="true"\nexport guaopencard_draw="true"\nexport JD_TRY="true"\nexport exjxbeans="true"\nexport DY_OPENALL="true"\n#抽奖\nexport opencard_draw=3\n#开启脚本依赖文件缺失修复\nexport ec_fix_dep="true" \n#开启脚本依赖文件更新\nexport ec_re_dep="true" \n#清空购物车\nexport JD_CART_REMOVE="true"\nexport JD_CART="true"\n#去掉多余的双十一红包脚本\nexport FLCODE=''\n#加购物车抽奖\nexport RUN_CAR=true\n#停用小额免密支付\nexport JD_PAY_CONTRACT=true\n</code></pre>\n<ul>\n<li>依赖管理</li>\n</ul>\n<pre><code class=\"language-yaml\">#nodejs依赖\ncrypto-js\t\nprettytable\t\ndotenv\t\njsdom\t\ndate-fns\t\ntough-cookie\t\ntslib\t\nws@7.4.3\t\nts-md5\t\njsdom -g\t\njieba\t\nfs\t\nform-data\t\njson5\t\nglobal-agent\t\npng-js\t\n@types/node\t\nrequire\t\ntypescript\t\njs-base64\t\naxios\n#pythone依赖\nrequests\t\ncanvas\t\nping3\t\njieba\t\naiohttp\t\nPyExecJS\n#Linux依赖\nbizCode\nbizMsg\nlxml\n</code></pre>\n<h4 id=\"其它\"><a class=\"anchor\" href=\"#其它\">#</a> 其它</h4>\n<pre><code class=\"language-bash\">#配置国内源\npip config --global set global.index-url https://mirrors.aliyun.com/pypi/simple/\npip config --global set install.trusted-host https://mirrors.aliyun.com\n\n#升级pip\npip install --upgrade pip\n\n#更新青龙\nql update\n\n#已知要安装的依赖(不安装部分脚本任务会失败)\npnpm install ds\n\n#一键安装所有依赖(基于Faker一键脚本安装的青龙\n可通过执行/ql/data/scripts下的QLDependency.sh脚本安装,如脚本已经更新则通过下面命令执行\ncurl -fsSL https://git.metauniverse-cn.com/https://raw.githubusercontent.com/shufflewzc/QLDependency/main/Shell/QLOneKeyDependency.sh | sh\n\n#一般出现这种错误:(缺依赖)\nError: Cannot find module 'xx'\n执行pnpm inLine truncated
|
||||
"tags": [
|
||||
"极空间",
|
||||
"Docker",
|
||||
@@ -118,7 +118,7 @@
|
||||
"url": "https://blog.jingxiyuan.cn/2022/10/21/Hexo-Theme-Shoka-Valine%E8%AF%84%E8%AE%BA%E9%85%8D%E7%BD%AE/",
|
||||
"title": "Hexo + Theme.Shoka + Valine评论配置",
|
||||
"date_published": "2022-10-21T03:48:00.000Z",
|
||||
"content_html": "<ul>\n<li>valine 评论需要 LeanCloud 支持</li>\n</ul>\n<h4 id=\"leancloud注册\"><a class=\"anchor\" href=\"#leancloud注册\">#</a> LeanCloud 注册</h4>\n<ol>\n<li>到<span class=\"exturl\" data-url=\"aHR0cHM6Ly93d3cubGVhbmNsb3VkLmNu\"> LeanCloud</span> 网站完成注册。</li>\n<li>创建应用。<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-11-54-32.jpg\" alt=\"\" /></li>\n<li>名称随便取,方案看自己选择。开发版免费但是有限制,商业版收费无限制。<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-11-54-32516c410640de936a.jpg\" alt=\"\" /></li>\n<li>点击配置按钮进行配置。<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-11-54-32267554cf6f62d3eb.jpg\" alt=\"\" /></li>\n<li>点击设置 - 应用凭证可获取 App ID 和 App Key<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-11-54-328c330a6fdd48d2c3.jpg\" alt=\"\" /></li>\n<li>点击设置 - 安全中心根据自己的需求配置<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-11-54-32204f14d87e95b59e.jpg\" alt=\"\" /></li>\n</ol>\n<h4 id=\"修改themeshoka配置\"><a class=\"anchor\" href=\"#修改themeshoka配置\">#</a> 修改 Theme.Shoka 配置</h4>\n<pre><code class=\"language-yml\">valine:\n appId: 粘贴5中获取的App ID #Your_appId\n appKey: 粘贴5中获取的App Key #Your_appkey\n placeholder: ヽ(○´∀`)ノ♪欢迎畅所欲言 # Comment box placeholder\n avatar: mp #默认头像设置 Gravatar style : mp, identicon, monsterid, wavatar, robohash, retro\n pageSize: 10 # Pagination size\n lang: zh-CN\n visitor: true # Article reading statistic 这个要设置为false,以免与 leancloud_visitors 突冲 \n NoRecordIP: false # Whether to record the commenter IP\n serverURLs: # When the custom domain name is enabled, fill it in here (it will be detected automatically by default, no need to fill in)\n powerMode: true\n tagMeta:\n visitor: 新朋友\n master: 博主\n friend: 小伙伴\n investor: 金主粑粑\n tagColor:\n master: "var(--color-orange)"\n friend: "var(--color-aqua)"\n investor: "var(--color-pink)"\n tagMember:\n master:\n # - hash of master@email.com\n # - hash of master2@email.com\n friend:\n # - hash of friend@email.com\n # - hash of friend2@email.com\n investor:\n # - hash of investor1@email.com\n</code></pre>\n",
|
||||
"content_html": "<ul>\n<li>valine 评论需要 LeanCloud 支持</li>\n</ul>\n<h4 id=\"leancloud注册\"><a class=\"anchor\" href=\"#leancloud注册\">#</a> LeanCloud 注册</h4>\n<ol>\n<li>到<span class=\"exturl\" data-url=\"aHR0cHM6Ly93d3cubGVhbmNsb3VkLmNu\"> LeanCloud</span> 网站完成注册。</li>\n<li>创建应用。<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-11-54-32.jpg\" alt=\"\" /></li>\n<li>名称随便取,方案看自己选择。开发版免费但是有限制,商业版收费无限制。<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-11-54-32516c410640de936a.jpg\" alt=\"\" /></li>\n<li>点击配置按钮进行配置。<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-11-54-32267554cf6f62d3eb.jpg\" alt=\"\" /></li>\n<li>点击设置 - 应用凭证可获取 App ID 和 App Key<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-11-54-328c330a6fdd48d2c3.jpg\" alt=\"\" /></li>\n<li>点击设置 - 安全中心根据自己的需求配置<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-11-54-32204f14d87e95b59e.jpg\" alt=\"\" /></li>\n</ol>\n<h4 id=\"修改themeshoka配置\"><a class=\"anchor\" href=\"#修改themeshoka配置\">#</a> 修改 Theme.Shoka 配置</h4>\n<pre><code class=\"language-yaml\">valine:\n appId: 粘贴5中获取的App ID #Your_appId\n appKey: 粘贴5中获取的App Key #Your_appkey\n placeholder: ヽ(○´∀`)ノ♪欢迎畅所欲言 # Comment box placeholder\n avatar: mp #默认头像设置 Gravatar style : mp, identicon, monsterid, wavatar, robohash, retro\n pageSize: 10 # Pagination size\n lang: zh-CN\n visitor: true # Article reading statistic 这个要设置为false,以免与 leancloud_visitors 突冲 \n NoRecordIP: false # Whether to record the commenter IP\n serverURLs: # When the custom domain name is enabled, fill it in here (it will be detected automatically by default, no need to fill in)\n powerMode: true\n tagMeta:\n visitor: 新朋友\n master: 博主\n friend: 小伙伴\n investor: 金主粑粑\n tagColor:\n master: "var(--color-orange)"\n friend: "var(--color-aqua)"\n investor: "var(--color-pink)"\n tagMember:\n master:\n # - hash of master@email.com\n # - hash of master2@email.com\n friend:\n # - hash of friend@email.com\n # - hash of friend2@email.com\n investor:\n # - hash of investor1@email.com\n</code></pre>\n",
|
||||
"tags": [
|
||||
"极空间",
|
||||
"Docker",
|
||||
@@ -135,7 +135,7 @@
|
||||
"url": "https://blog.jingxiyuan.cn/2022/10/21/%E6%9E%81%E7%A9%BA%E9%97%B4Docker%E7%89%88mariadb%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AE/",
|
||||
"title": "极空间Docker版mariadb安装与配置",
|
||||
"date_published": "2022-10-21T01:06:00.000Z",
|
||||
"content_html": "<h4 id=\"介绍\"><a class=\"anchor\" href=\"#介绍\">#</a> 介绍</h4>\n<ul>\n<li>mariadb 属于 mysql 的一个分支,完全兼容 mysql,使用方式和 mysql 无区别。</li>\n</ul>\n<h4 id=\"安装\"><a class=\"anchor\" href=\"#安装\">#</a> 安装</h4>\n<ul>\n<li>本文介绍安装的镜像为 linuxserver_mariadb 的 10.5.13-r0-ls45,原则上使用最新版即可</li>\n<li>配置文件映射<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-09-20-56.jpg\" alt=\"\" /></li>\n<li>端口<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-09-21-49.jpg\" alt=\"\" /></li>\n<li>环境(MYSQL_ROOT_PASSWORD 为数据库 root 用户密码)<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-09-22-43.jpg\" alt=\"\" /></li>\n<li>到此已经可以在内网使用了,连接方法同 mysql 一致</li>\n</ul>\n<h4 id=\"配置\"><a class=\"anchor\" href=\"#配置\">#</a> 配置</h4>\n<ul>\n<li>此处配置为 nginx 反向代理,配置完成后可在外网连接访问</li>\n</ul>\n<pre><code class=\"language-conf\">stream {\n\t\n\t#极空间-docker-mariadb\n\tupstream mariadb {\n\t\thash $remote_addr consistent;\n\t\tserver mariadb的ip:端口;\n\t}\n\n\tserver {\n\t\tlisten 监听端口;\n\n\t\tproxy_connect_timeout 30s;\n\t\tproxy_timeout 300s;\n\t\tproxy_pass mariadb;\n\t}\n \n}\n</code></pre>\n",
|
||||
"content_html": "<h4 id=\"介绍\"><a class=\"anchor\" href=\"#介绍\">#</a> 介绍</h4>\n<ul>\n<li>mariadb 属于 mysql 的一个分支,完全兼容 mysql,使用方式和 mysql 无区别。</li>\n</ul>\n<h4 id=\"安装\"><a class=\"anchor\" href=\"#安装\">#</a> 安装</h4>\n<ul>\n<li>本文介绍安装的镜像为 linuxserver_mariadb 的 10.5.13-r0-ls45,原则上使用最新版即可</li>\n<li>配置文件映射<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-09-20-56.jpg\" alt=\"\" /></li>\n<li>端口<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-09-21-49.jpg\" alt=\"\" /></li>\n<li>环境(MYSQL_ROOT_PASSWORD 为数据库 root 用户密码)<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/21/2022-10-21-09-22-43.jpg\" alt=\"\" /></li>\n<li>到此已经可以在内网使用了,连接方法同 mysql 一致</li>\n</ul>\n<h4 id=\"配置\"><a class=\"anchor\" href=\"#配置\">#</a> 配置</h4>\n<ul>\n<li>此处配置为 nginx 反向代理,配置完成后可在外网连接访问</li>\n</ul>\n<pre><code class=\"language-yaml\">stream {\n\t\n\t#极空间-docker-mariadb\n\tupstream mariadb {\n\t\thash $remote_addr consistent;\n\t\tserver mariadb的ip:端口;\n\t}\n\n\tserver {\n\t\tlisten 监听端口;\n\n\t\tproxy_connect_timeout 30s;\n\t\tproxy_timeout 300s;\n\t\tproxy_pass mariadb;\n\t}\n \n}\n</code></pre>\n",
|
||||
"tags": [
|
||||
"极空间",
|
||||
"Docker",
|
||||
@@ -189,7 +189,7 @@
|
||||
"url": "https://blog.jingxiyuan.cn/2022/10/17/redis%E4%B8%BB%E4%BB%8E%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE%E8%AE%B0%E5%BD%95/",
|
||||
"title": "redis主从基础配置",
|
||||
"date_published": "2022-10-17T06:07:00.000Z",
|
||||
"content_html": "<h4 id=\"主服务\"><a class=\"anchor\" href=\"#主服务\">#</a> 主服务</h4>\n<ol>\n<li>基础配置</li>\n</ol>\n<pre><code class=\"language-conf\">port 6379\nrequirepass 123456(密码,建议不设置)\nvm-enabled no (虚拟内存,内存够的情况下可以不使用)\nmaxmemory 1GB(告诉Redis当使用了多少物理内存后就开始拒绝后续的写入)\nbind 127.0.0.1 (注释掉,否则不能外部连接)\nrdbchecksum no(持久化数据检查)\nlist-max-ziplist-size 1024(ziplist的最大容量,正数为自己指定的大小。负数-1到-5为对应的值4到64Kb)\nlist-compress-depth 20(quicklist的两端多少个node不压缩,0为全部不压缩)\n</code></pre>\n<pre><code class=\"language-bash\">sysctl vm.overcommit_memory=1 (立即生效)\n修改/etc/sysctl.conf添加vm.overcommit_memory=1(表示内核允许分配所有的物理内存,而不管当前的内存状态如何。Redis的RDB持久化实现是folk一个子进程,然后让子进程将内存镜像dump到RDB文件中。理论上来说是需要跟父进程一样的内存空间,但是由于linux很早就支持的copy-on-write技术,所以实际上并不需要这么多的物理内存的。)\n</code></pre>\n<ol start=\"2\">\n<li>禁用透明大页(影响性能)</li>\n</ol>\n<pre><code class=\"language-bash\">需要sudo su 切换到root身份(sudo 没用)\necho never > /sys/kernel/mm/transparent_hugepage/enabled\n修改/etc/init.d/redis-server,加入/bin/echo never > /sys/kernel/mm/transparent_hugepage/enabled\n</code></pre>\n<ol start=\"3\">\n<li>修复 TCP 警告</li>\n</ol>\n<pre><code class=\"language-bash\">sysctl net.core.somaxconn=1024(立即生效)\n修改/etc/sysctl.conf添加net.core.somaxconn=1024\n</code></pre>\n<ol start=\"4\">\n<li>客户端缓冲区限制</li>\n</ol>\n<pre><code class=\"language-conf\">客户端的输出缓冲区的限制,因为某种原因客户端从服务器读取数据的速度不够快,可用于强制断开连接(一个常见的原因是一个发布 / 订阅客户端消费消息的速度无法赶上生产它们的速度)。\n可以三种不同客户端的方式进行设置:\nnormal -> 正常客户端\nslave -> slave 和 MONITOR 客户端\npubsub -> 至少订阅了一个 pubsub channel 或 pattern 的客户端\n语法 :\nclient-output-buffer-limit <class><hard limit> <soft limit> <soft seconds>\n一旦达到硬限制客户端会立即断开,或者达到软限制并保持达成的指定秒数(连续)。\n例如,如果硬限制为 32 兆字节和软限制为 16 兆字节 /10 秒,客户端将会立即断开。如果输出缓冲区的大小达到 32 兆字节,客户端达到 16 兆字节和连续超过了限制 10 秒,也将断开连接。默认 normal 客户端不做限制,因为他们在一个请求后未要求时(以推的方式)不接收数据,\n只有异步客户端可能会出现请求数据的速度比它可以读取的速度快的场景。\n把硬限制和软限制都设置为 0 来禁用该特性\nclient-output-buffer-limit normal 0 0 0\nclient-output-buffer-limit slave 5gb 512mb 60\nclient-output-buffer-limit pubsub 32mb 8mb 60\n</code></pre>\n<ol start=\"5\">\n<li>持久化配置</li>\n</ol>\n<pre><code class=\"language-conf\">---关闭RDB持久化---\nsave ""\n默认配置如下:\nsave 900 1 #900秒内有1次更新就持久化\nsave 300 10 #300秒内有10次更新就持久化\nsave 60 10000 #60秒内有10000次更新就持久化\n---关闭RDB持久化---\n主从同步支持两种策略,即disk和socket方式。\n新的slave端和重连的salve端不允许去继续同步进程,这被称之为“完全同步”。\n一个RDB文件从master端传到slave端,分为两种情况:\n1、支持disk:master端将RDB file写到disk,稍后再传送到slave端;\n2、无磁盘diskless:master端直接将RDB file传到slave socket,不需要与disk进行交互。无磁盘diskless方式适合磁盘读写速度慢但网络带宽非常高的环境。\nrepl-diskless-sync no 默认不使用diskless同步方式\nrepl-diskless-sync-delay 30 无磁盘diskless方式在进行数据传递之前会有一个时间的延迟,以便slave端能够进行到待传送的目标队列中,这个时间默认是5秒\nrepl-ping-slave-period 60 slave端向server端发送pings的时间区间设置,默认为10秒\nrepl-timeout 3600 设置超时时间\nrepl-disable-tcp-nodelay no 是否启用TCP_NODELAY,如果启用则会使用少量的TCP包和带宽去进行数据传输到slave端,当然速度会比较慢;如果不启用则传输速度比较快,但是会占用比较多的带宽。\nrepl-backlog-size 1mb 设置backlog的大小,backlog是一个缓冲区,在slave端失连时存放要同步到slave的数据,因此当一个slave要重连时,经常是不需要完全同步的,执行局部同步就足够了。\nbacklog设置的越Line truncated
|
||||
"content_html": "<h4 id=\"主服务\"><a class=\"anchor\" href=\"#主服务\">#</a> 主服务</h4>\n<ol>\n<li>基础配置</li>\n</ol>\n<pre><code class=\"language-yaml\">port 6379\nrequirepass 123456(密码,建议不设置)\nvm-enabled no (虚拟内存,内存够的情况下可以不使用)\nmaxmemory 1GB(告诉Redis当使用了多少物理内存后就开始拒绝后续的写入)\nbind 127.0.0.1 (注释掉,否则不能外部连接)\nrdbchecksum no(持久化数据检查)\nlist-max-ziplist-size 1024(ziplist的最大容量,正数为自己指定的大小。负数-1到-5为对应的值4到64Kb)\nlist-compress-depth 20(quicklist的两端多少个node不压缩,0为全部不压缩)\n</code></pre>\n<pre><code class=\"language-bash\">sysctl vm.overcommit_memory=1 (立即生效)\n修改/etc/sysctl.conf添加vm.overcommit_memory=1(表示内核允许分配所有的物理内存,而不管当前的内存状态如何。Redis的RDB持久化实现是folk一个子进程,然后让子进程将内存镜像dump到RDB文件中。理论上来说是需要跟父进程一样的内存空间,但是由于linux很早就支持的copy-on-write技术,所以实际上并不需要这么多的物理内存的。)\n</code></pre>\n<ol start=\"2\">\n<li>禁用透明大页(影响性能)</li>\n</ol>\n<pre><code class=\"language-bash\">需要sudo su 切换到root身份(sudo 没用)\necho never > /sys/kernel/mm/transparent_hugepage/enabled\n修改/etc/init.d/redis-server,加入/bin/echo never > /sys/kernel/mm/transparent_hugepage/enabled\n</code></pre>\n<ol start=\"3\">\n<li>修复 TCP 警告</li>\n</ol>\n<pre><code class=\"language-bash\">sysctl net.core.somaxconn=1024(立即生效)\n修改/etc/sysctl.conf添加net.core.somaxconn=1024\n</code></pre>\n<ol start=\"4\">\n<li>客户端缓冲区限制</li>\n</ol>\n<pre><code class=\"language-yaml\">客户端的输出缓冲区的限制,因为某种原因客户端从服务器读取数据的速度不够快,可用于强制断开连接(一个常见的原因是一个发布 / 订阅客户端消费消息的速度无法赶上生产它们的速度)。\n可以三种不同客户端的方式进行设置:\nnormal -> 正常客户端\nslave -> slave 和 MONITOR 客户端\npubsub -> 至少订阅了一个 pubsub channel 或 pattern 的客户端\n语法 :\nclient-output-buffer-limit <class><hard limit> <soft limit> <soft seconds>\n一旦达到硬限制客户端会立即断开,或者达到软限制并保持达成的指定秒数(连续)。\n例如,如果硬限制为 32 兆字节和软限制为 16 兆字节 /10 秒,客户端将会立即断开。如果输出缓冲区的大小达到 32 兆字节,客户端达到 16 兆字节和连续超过了限制 10 秒,也将断开连接。默认 normal 客户端不做限制,因为他们在一个请求后未要求时(以推的方式)不接收数据,\n只有异步客户端可能会出现请求数据的速度比它可以读取的速度快的场景。\n把硬限制和软限制都设置为 0 来禁用该特性\nclient-output-buffer-limit normal 0 0 0\nclient-output-buffer-limit slave 5gb 512mb 60\nclient-output-buffer-limit pubsub 32mb 8mb 60\n</code></pre>\n<ol start=\"5\">\n<li>持久化配置</li>\n</ol>\n<pre><code class=\"language-yaml\">---关闭RDB持久化---\nsave ""\n默认配置如下:\nsave 900 1 #900秒内有1次更新就持久化\nsave 300 10 #300秒内有10次更新就持久化\nsave 60 10000 #60秒内有10000次更新就持久化\n---关闭RDB持久化---\n主从同步支持两种策略,即disk和socket方式。\n新的slave端和重连的salve端不允许去继续同步进程,这被称之为“完全同步”。\n一个RDB文件从master端传到slave端,分为两种情况:\n1、支持disk:master端将RDB file写到disk,稍后再传送到slave端;\n2、无磁盘diskless:master端直接将RDB file传到slave socket,不需要与disk进行交互。无磁盘diskless方式适合磁盘读写速度慢但网络带宽非常高的环境。\nrepl-diskless-sync no 默认不使用diskless同步方式\nrepl-diskless-sync-delay 30 无磁盘diskless方式在进行数据传递之前会有一个时间的延迟,以便slave端能够进行到待传送的目标队列中,这个时间默认是5秒\nrepl-ping-slave-period 60 slave端向server端发送pings的时间区间设置,默认为10秒\nrepl-timeout 3600 设置超时时间\nrepl-disable-tcp-nodelay no 是否启用TCP_NODELAY,如果启用则会使用少量的TCP包和带宽去进行数据传输到slave端,当然速度会比较慢;如果不启用则传输速度比较快,但是会占用比较多的带宽。\nrepl-backlog-size 1mb 设置backlog的大小,backlog是一个缓冲区,在slave端失连时存放要同步到slave的数据,因此当一个slave要重连时,经常是不需要完全同步的,执行局部同步就足够了。\nbacklog设置的越Line truncated
|
||||
"tags": [
|
||||
"Linux",
|
||||
"服务",
|
||||
@@ -201,7 +201,7 @@
|
||||
"url": "https://blog.jingxiyuan.cn/2022/10/14/nginx%E5%85%81%E8%AE%B8%E8%B7%A8%E5%9F%9F%E8%8E%B7%E5%8F%96cookies%E6%96%B9%E6%B3%95/",
|
||||
"title": "nginx允许跨域获取cookie的方法",
|
||||
"date_published": "2022-10-14T09:13:00.000Z",
|
||||
"content_html": "<h4 id=\"使用场景\"><a class=\"anchor\" href=\"#使用场景\">#</a> 使用场景</h4>\n<p> 在 A 域名的页面向 B 域名提交数据时需要代入 B 域名的 cookie,否则 B 域名会跳转到登陆页面。解决方式需要使用到 nginx 反向代理,配置如下:</p>\n<pre><code class=\"language-conf\">server {\n\tlisten port ssl http2;\n\tserver_name xxx.com;\n\tssl_certificate_key /xxx.key;\n\tssl_certificate /xxx.pem;\n\tproxy_cookie_path ~(.*) "$1; SameSite=None; secure; httponly";\n\n\tlocation / {\n\t\t#允许镶套的方式(可以同域镶套、指定域名镶套或者所有域名镶套)\n\t\tadd_header X-Frame-Options ALLOWALL; #允许被所有域名镶套\n\t\tproxy_pass http://xxx;\n\t}\n}\n</code></pre>\n",
|
||||
"content_html": "<h4 id=\"使用场景\"><a class=\"anchor\" href=\"#使用场景\">#</a> 使用场景</h4>\n<p> 在 A 域名的页面向 B 域名提交数据时需要代入 B 域名的 cookie,否则 B 域名会跳转到登陆页面。解决方式需要使用到 nginx 反向代理,配置如下:</p>\n<pre><code class=\"language-yaml\">server {\n\tlisten port ssl http2;\n\tserver_name xxx.com;\n\tssl_certificate_key /xxx.key;\n\tssl_certificate /xxx.pem;\n\tproxy_cookie_path ~(.*) "$1; SameSite=None; secure; httponly";\n\n\tlocation / {\n\t\t#允许镶套的方式(可以同域镶套、指定域名镶套或者所有域名镶套)\n\t\tadd_header X-Frame-Options ALLOWALL; #允许被所有域名镶套\n\t\tproxy_pass http://xxx;\n\t}\n}\n</code></pre>\n",
|
||||
"tags": [
|
||||
"Linux",
|
||||
"服务",
|
||||
@@ -269,7 +269,7 @@
|
||||
"url": "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/",
|
||||
"title": "nginx负载均衡配置",
|
||||
"date_published": "2022-09-27T06:45:00.000Z",
|
||||
"content_html": "<h2 id=\"nginx负载均衡配置\"><a class=\"anchor\" href=\"#nginx负载均衡配置\">#</a> nginx 负载均衡配置</h2>\n<ol>\n<li>轮询(默认)</li>\n</ol>\n<p> <em>每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器 down 掉,能自动剔除。</em></p>\n<pre><code class=\"language-conf\">upstream my_server {\n\tserver 192.168.0.2:8080;\n\tserver 192.168.0.3:8080;\n}\n\nserver {\n\tlisten 80;\n\tserver_name 192.168.0.1;\n\n\t# Path to the root of your installation\n\tlocation / {\n\t\tproxy_pass http://my_server;\n\t}\n\t\n}\n</code></pre>\n<ol start=\"2\">\n<li>weight 权重策略</li>\n</ol>\n<p> <em>weight 代表权重,默认为 1,权重越高被分配的客户端越多,指定轮询几率。weight 和访问比率成正比,用于后端服务器性能不均的情况。</em></p>\n<pre><code class=\"language-conf\">upstream my_server {\n\tserver 192.168.0.2:8080 weight=1;\n\tserver 192.168.0.3:8080 weight=2;\n}\n\nserver {\n\tlisten 80;\n\tserver_name 192.168.0.1;\n\n\t# Path to the root of your installation\n\tlocation / {\n\t\tproxy_pass http://my_server;\n\t}\n\t\n}\n</code></pre>\n<ol start=\"3\">\n<li>ip_hash</li>\n</ol>\n<p> <em>每个请求按访问 ip 的 hash 结果分配,这样每个访客固定访问一个后端服务器,可以解决 session 的问题。</em></p>\n<pre><code class=\"language-conf\">upstream my_server {\n\tip_hash;\n\tserver 192.168.0.2:8080;\n\tserver 192.168.0.3:8080;\n}\n\nserver {\n\tlisten 80;\n\tserver_name 192.168.0.1;\n\n\t# Path to the root of your installation\n\tlocation / {\n\t\tproxy_pass http://my_server;\n\t}\n\t\n}\n</code></pre>\n<ol start=\"4\">\n<li>fair (第三方)</li>\n</ol>\n<p> <em>按后端服务器的响应时间来分配请求,响应时间短的优先分配。</em></p>\n<pre><code class=\"language-conf\">upstream my_server {\n\tserver 192.168.0.2:8080;\n\tserver 192.168.0.3:8080;\n\tfair;\n}\n\nserver {\n\tlisten 80;\n\tserver_name 192.168.0.1;\n\n\t# Path to the root of your installation\n\tlocation / {\n\t\tproxy_pass http://my_server;\n\t}\n\t\n}\n</code></pre>\n<ol start=\"5\">\n<li>动静分离</li>\n</ol>\n<p> <em>把静态的资源,比如图片,css,js 等先加载到 Nginx 的服务器里。</em></p>\n",
|
||||
"content_html": "<h2 id=\"nginx负载均衡配置\"><a class=\"anchor\" href=\"#nginx负载均衡配置\">#</a> nginx 负载均衡配置</h2>\n<ol>\n<li>轮询(默认)</li>\n</ol>\n<p> <em>每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器 down 掉,能自动剔除。</em></p>\n<pre><code class=\"language-yaml\">upstream my_server {\n\tserver 192.168.0.2:8080;\n\tserver 192.168.0.3:8080;\n}\n\nserver {\n\tlisten 80;\n\tserver_name 192.168.0.1;\n\n\t# Path to the root of your installation\n\tlocation / {\n\t\tproxy_pass http://my_server;\n\t}\n\t\n}\n</code></pre>\n<ol start=\"2\">\n<li>weight 权重策略</li>\n</ol>\n<p> <em>weight 代表权重,默认为 1,权重越高被分配的客户端越多,指定轮询几率。weight 和访问比率成正比,用于后端服务器性能不均的情况。</em></p>\n<pre><code class=\"language-yaml\">upstream my_server {\n\tserver 192.168.0.2:8080 weight=1;\n\tserver 192.168.0.3:8080 weight=2;\n}\n\nserver {\n\tlisten 80;\n\tserver_name 192.168.0.1;\n\n\t# Path to the root of your installation\n\tlocation / {\n\t\tproxy_pass http://my_server;\n\t}\n\t\n}\n</code></pre>\n<ol start=\"3\">\n<li>ip_hash</li>\n</ol>\n<p> <em>每个请求按访问 ip 的 hash 结果分配,这样每个访客固定访问一个后端服务器,可以解决 session 的问题。</em></p>\n<pre><code class=\"language-yaml\">upstream my_server {\n\tip_hash;\n\tserver 192.168.0.2:8080;\n\tserver 192.168.0.3:8080;\n}\n\nserver {\n\tlisten 80;\n\tserver_name 192.168.0.1;\n\n\t# Path to the root of your installation\n\tlocation / {\n\t\tproxy_pass http://my_server;\n\t}\n\t\n}\n</code></pre>\n<ol start=\"4\">\n<li>fair (第三方)</li>\n</ol>\n<p> <em>按后端服务器的响应时间来分配请求,响应时间短的优先分配。</em></p>\n<pre><code class=\"language-yaml\">upstream my_server {\n\tserver 192.168.0.2:8080;\n\tserver 192.168.0.3:8080;\n\tfair;\n}\n\nserver {\n\tlisten 80;\n\tserver_name 192.168.0.1;\n\n\t# Path to the root of your installation\n\tlocation / {\n\t\tproxy_pass http://my_server;\n\t}\n\t\n}\n</code></pre>\n<ol start=\"5\">\n<li>动静分离</li>\n</ol>\n<p> <em>把静态的资源,比如图片,css,js 等先加载到 Nginx 的服务器里。</em></p>\n",
|
||||
"tags": [
|
||||
"Linux",
|
||||
"服务",
|
||||
|
||||
Reference in new issue
Block a user