Docker+Nginx实现端口复用

前言 这个博客建立之初,为了图方便以及便宜买的是阿里云的服务器。但随着需求的增加才知道阿里云安全组这么个东西,就是说服务器默认只开放22(SSH), 3389(RDP), 80(HTTP)和443(HTTPS)这几个端口。如果想要在服务器上整点别的活,就需要设置安全组放行,或者使用将要提到的端口复用。 Docker+Nginx初步 Docker安装 我使用的是 $ cat /proc/version Linux version 5.15.0-86-generic (buildd@lcy02-amd64-086) (gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #96-Ubuntu SMP Wed Sep 20 08:23:49 UTC 2023 具体操作参考runoob和aliyun,大致如下(分别为更新apt,下载依赖,设置仓库和安装docker) sudo apt-get update sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common sudo add-apt-repository \ "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \ $(lsb_release -cs) \ stable" sudo apt-get install docker-ce docker-ce-cli containerd.io 之后pull下载Nginx以及其他服务的镜像。 docker-compose+Nginx配置 在进行反向代理之前,先尝试让Nginx正常工作。和直接使用Nginx相比,容器内部和服务器在网络和文件上都是隔离的,因此需要...

Docker Nginx 2414字

LaTeX Fonts and More

本意是想让博客看起来像是$\LaTeX$文档。 1. 使用$\LaTeX$字体 1.1 换个字体 如果仅仅是想更换字体,那么只需要先找到这部分内容对应的css样式文件修改即可。比如我的主题中正文部分的样式文件位于assets/css/common/main.css,接下来指定font-family参数: .main { font-family: default_font_1, default_font_2, serif; } 之后Hugo会首先尝试使用第一种字体,如果系统中不存在该字体,则会使用第二种字体,以此类推。最后的serif指使用系统默认的衬线字体。 1.2 使用自定义字体 其实使用自定义字体最快的方式就是选择使用自己喜欢字体的主题,比如我一开始就想用texify3这个$\LaTeX$风格的主题,但是后来发现魔改难度比较大于是换了现在的主题。所以我就想是不是只要把texify3主题中的字体和样式文件复制到我的主题的对应位置就行了? texify3主题中正文部分的结构文件位于layouts/_default/baseof.html,样式文件位于assets/sass/layouts/common.scss,字体调用的样式文件位于assets/sass/fonts.scss,字体文件位于static/fonts/,具体来说 baseof.html: <div id="wrapper"> {{ block "main" . }}{{ end }} </div> common.scss: @import "../fonts"; #wrapper { font-family: "Latin Modern Roman", "Times New Roman", serif; } fonts.scss: @font-face { font-display: swap; font-family: 'Latin Modern Roman'; font-style: normal; font-weight: normal; src: url('../fonts/lmroman-normal.woff'); } 有趣的事情发生了,fonts.scss中使用的路径十分奇怪,既不是相对结构文件的路径,也不是相对样式文件的路径,但却可行! ChatGPT对于src参数的解释是相对样式文件的路径,但是如果使用“正确”的路径../../static/fonts/lmroman-normal.woff会发现不可行。 另外使用绝对路径/Users/.../fonts/lmroman-normal.woff或是{{ lmroman-normal.woff | absURL}}也都不可行。 更糟糕的是,复制到我的主题后,连一开始的../fonts/lmroman-normal.woff也不可行了。 起初我以为是scss格式的问题,因为在texify3中使用scss样式文件时有转译为css格式的逻辑 {{ $options := dict "transpiler" "dartsass" "targetPath" "css/common....

Hugo 3890字

Attributes and Methods

本文作为“一切皆对象”的下篇,主要介绍对象的属性(attribute)和方法(method)。 什么是属性和方法? 在Python官方术语对照表中是这样定义的: Attribute: A value associated with an object which is usually referenced by name using dotted expressions. It is possible to give an object an attribute whose name is not an identifier as defined by Identifiers and keywords, for example using setattr(), if the object allows it. Such an attribute will not be accessible using a dotted expression, and would instead need to be retrieved with getattr(). Method: A function which is defined inside a class body....

Python 3311字

Everything is an object in Python

本文主要想解决的问题是:在Python中什么是“一切皆对象”? 什么是对象? 在Python官方术语对照表中是这样定义的: Object: Any data with state (attributes or value) and defined behavior (methods). 什么是属性(attribute)和方法(method): Attribute: A value associated with an object which is usually referenced by name using dotted expressions. Method: A function which is defined inside a class body. If called as an attribute of an instance of that class, the method will get the instance object as its first argument (which is usually called self). 什么是函数(function)和类(class):...

Python 2048字

BOMB: Birth Of My Blog

用于记录我的博客的诞生 Step 0.1: 安装 Hugo 安装 Git: 用于和 GitHub 仓库的交互(如上传本地网页和下载主题或软件) brew install git Git is a distributed version control system. 安装 Go: 下载安装包安装即可 Go is a statically typed, compiled high-level programming language. 安装 Dart Sass: 有些主题(如TeXify3)的渲染需要用到 brew install sass/sass/sass Sass is a preprocessor scripting language that is interpreted or compiled into CSS. 完成之后会在 myblog 文件夹创建两个名为 node_modules 和 resources 的文件夹和两个 json 文件 遇到的报错: 问题参考这里,解决:先 rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" Error: Cannot find module 'autoprefixer',解决:需要先安装 node....

Hugo 989字