docker部署思源笔记并配置nginx支持https

docker compsoe的完整配置

docker-compose.yml

# 构建docker-compose项目
# docker compose --log-level INFO up -- build
# docker compose --log-level INFO up -d --build

version: '3'
services:
  terwer-nginx:
    image: terwer/nginx:1.15.9
    container_name: terwer-nginx
    build:
      context: ./terwer-nginx
      dockerfile: Dockerfile
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./terwer-nginx/nginx.conf:/etc/nginx/conf.d/default.conf
      - ./terwer-nginx/data/nginx/log:/var/log/nginx
      - ./terwer-nginx/ssl/v4.pem:/etc/ssl/v4.pem
      - ./terwer-nginx/ssl/v4.key:/etc/ssl/v4.key
    restart: "no"
  siyuan-nginx:
    image: siyuan/nginx:1.15.9
    container_name: siyuan-nginx
    build:
      context: ./siyuan-nginx
      dockerfile: Dockerfile
    ports:
      - "9000:9000"
      - "9001:9001"
    volumes:
      - ./siyuan-nginx/nginx.conf:/etc/nginx/conf.d/default.conf
      - ./siyuan-nginx/data/nginx/log:/var/log/nginx
      - ./siyuan-nginx/ssl/siyuan.pem:/etc/ssl/siyuan.pem
      - ./siyuan-nginx/ssl/siyuan.key:/etc/ssl/siyuan.key
    restart: "no"

Terwer...大约 2 分钟经验分享配置支持完整dockersiyuan思源笔记nginxdocker-compose
利用Nginx的stream实现Netty的TCP负载均衡

随着设备连接数增多,单台服务器支撑的TCP长连接数有限,这个时候程序架构就需要改变,一般都会采取横向扩展,增加多台服务器程序。怎么将TCP长连接均衡的路由到不同的服务器,这个时候就需要实现负载均衡了。


Terwer...大约 2 分钟实用技巧经验分享nettynginxloadbanancetcp
Mac安装Nginx

Mac安装Nginx

安装

brew install nginx

结果如下:

==> Installing nginx
==> Pouring nginx--1.21.6.monterey.bottle.tar.gz
==> Caveats
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

To restart nginx after an upgrade:
  brew services restart nginx
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/nginx/bin/nginx -g daemon off;
==> Summary
🍺  /usr/local/Cellar/nginx/1.21.6: 26 files, 2.2MB
==> Running `brew cleanup nginx`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> nginx
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

To restart nginx after an upgrade:
  brew services restart nginx
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/nginx/bin/nginx -g daemon off;
➜  ~

Terwer...小于 1 分钟经验分享实用技巧macnginx
利用Nginx的map实现301重定向

很多时候,我们先写了一篇文章,但是还没来得及命名号好友好的url,就已经发出去了。后来我们完成了文章,修改了文章链接,但是这时候原先的文章已经被收录了,用户点击就会导致404。这样是非常不好的,一个比较好的办法就是利用Nginx的301永久重定向,这样用户访问失效的页面就能自动跳转到新压面,还不会影响SEO。


Terwer...大约 3 分钟经验分享实用技巧nginxseo301