Nginx Apache2 反向代理 SSL

Apache2

<VirtualHost *:443>
DocumentRoot /var/www/html
ServerName pan.voidspace.cn
SSLEngine on
SSLCertificateFile "/root/.acme.sh/voidspace.cn_ecc/*****.cer"
SSLCertificateKeyFile "/root/.acme.sh/*****.key"
ErrorLog /var/www/logs/443panerror.log
CustomLog /var/www/logs/443panaccess.log combined
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
SSLProxyEngine On
ProxyPreserveHost On
SSLProxyVerify none
# 不验证后端服务器的证书
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
AllowEncodedSlashes NoDecode
ProxyPass "/" "https://127.0.0.1:5212/" nocanon

</VirtualHost>

Nginx

server{
listen 443 ssl;
listen [::]:443 ssl;
listen 777 ssl;
listen [::]:777 ssl;
#对应你的域名
server_name tasks.voidspace.cn;
gzip on;
gzip_comp_level 4;
gzip_types application/javascript text/css application/json;
gzip_vary on;
gzip_static on;
ssl_certificate /home/orangepi/.acme.sh/*****.cer;
ssl_certificate_key /home/orangepi/.acme.sh/*****.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
#如果是静态文件,直接指向目录,如果是动态应用,用proxy_pass转发一下
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_max_temp_file_size 0;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_pass http://localhost:58088;
}
}

Linux Deploy 提权

提权指令

在安卓设备上,为apache2的www-data用户提升到系统管理网络的用户权限上,使得可以进行反代和访问网络

usermod -a -G aid_net_bt_admin,aid_net_bt,aid_inet,aid_net_raw,aid_net_admin,aid_net_bw_stats,aid_net_bw_acct,aid_readproc www-data

查看目录占用空间 Vizex

安装

要求python > 3.7

pip install vizex

查看文件目录下情况

vizexdf -ads size

查看系统储存设备占用

vizex --details

C++ VSCode 运行环境配置

Tasks.json

{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}

Launch.json

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [
/*
args的作用是再调用可执行文件是添加参数
下面两句命令的作用分别是:
1.将in.txt文件输入进可执行文件
2.将可执行文件的结果输出进out.txt文件
*/
"<${workspaceFolder}/.vscode/oi/in.txt",
">${workspaceFolder}/.vscode/oi/out.txt"
],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
},
{
"description": "防止 gdb 打开标准库函数",
"text": "-interpreter-exec console \"skip -rfu std::.*\"",
"ignoreFailures": false
}
],
"symbolLoadInfo": {
"loadAll": false,
"exceptionList": ""
},
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}

Redmine 项目平台部署

Docker 安装

方法一:docker-compose (推荐)

version: "3"

networks:
bridge:

volumes:
redmine-plugins: {}
redmine-themes: {}
redmine-data: {}

services:
redmine:
image: redmine
ports:
- 58088:3000
volumes:
- ./plugins:/usr/src/redmine/plugins
- ./themes:/usr/src/redmine/public/themes
- ./data:/usr/src/redmine/files
environment:
REDMINE_DB_MYSQL: db
REDMINE_DB_PASSWORD: pw_example
REDMINE_SECRET_KEY_BASE: supersecretkey

restart: always

db:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: pw_example
MYSQL_DATABASE: redmine
volumes:
- ./mysql/conf:/etc/mysql/conf.d
- ./mysql/data:/var/lib/mysql

保存为docker-compose.yml之后运行即可

docker-compose up -d

方法二:直接启动

Mysql 启动(以下内容的password需要改为自己使用的地址)

docker run  --name mysql -e MYSQL_ROOT_PASSWORD="password" -e MYSQL_DATABASE=redmine -d mysql --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

Redmine

docker run -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD="password" -e MYSQL_DATABASE=redmine -d mysql --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

移除插件指令

rake redmine:plugins:migrate NAME=redmine_hearts VERSION=0 RAILS_ENV=production

控制问题显示字域所在位置

app\views\issues\show.html.erb

相关Docker操作

备份 Mysql 进入到容器中

mysqldump -u root -p redmine > /home/backup.sql

再执行cp复制

docker cp [docker代号]:/home/backup.sql ./backup.sql

即可完成复制导出

删除部分 issue 核心字段

笨办法,直接删除相关代码 找到 .html.erb 修改即可

调节图片显示

让长图片在桌面端正常显示

找到 public/stylesheets/application.css 替换

.filecontent-container > .filecontent {
position: absolute;
max-height: 100%;
max-width: 100%;
}

.filecontent-container > .filecontent {
position: absolute;
/* max-height: 100%; */
max-width: 80%;
}

@media
only screen and (max-width: 700px),
(min-device-width: 700px) and (max-device-width: 700px){
.filecontent-container > .filecontent {
position: absolute;
max-width: 100% !important;
}
}

MariaDB 部署

安装MariaDB

sudo apt install -y mariadb-server mariadb-client

初始化设置

sudo mysql_secure_installation

创建数据库

进入管理

mysql -u root -p

创建

CREATE DATABASE jira CHARACTER SET utf8 COLLATE utf8_bin;
CREATE USER 'jira'@'localhost' IDENTIFIED BY 'jira';
grant all on jira.* to 'jira'@'%';

测试用户

mysql -u jira -h localhost -p

Openssh 配置

安装server

sudo apt install openssh-server

配置root登录

sudo vim /etc/ssh/sshd_config

添加一行

PermitRootLogin yes

重启服务

sudo /etc/init.d/ssh restart

Nomachine 虚拟桌面 分辨率调整

使用虚拟桌面

安装基础组件

sudo apt-get install  xserver-xorg-core-hwe-18.04
sudo apt-get install xserver-xorg-video-dummy-hwe-18.04 --fix-missing

修改配置文件,以创建一个虚拟桌面

vim /usr/share/X11/xorg.conf.d/xorg.conf

写入以下内容

Section "Monitor"
Identifier "Monitor0"
HorizSync 5.0 - 1000.0
VertRefresh 5.0 - 200.0
# https://arachnoid.com/modelines/
# 1920x1080 @ 60.00 Hz (GTF) hsync: 67.08 kHz; pclk: 172.80 MHz
Modeline "2560x1600" 47.12 2560 2592 2768 2800 1600 1639 1642 1681
Modeline "2560x1440" 42.12 2560 2592 2752 2784 1440 1475 1478 1513
Modeline "1920x1080" 23.53 1920 1952 2040 2072 1080 1106 1108 1135
EndSection

Section "Device"
Identifier "Card0"
Driver "dummy"
VideoRam 256000
EndSection

Section "Screen"
DefaultDepth 24
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
SubSection "Display"
Depth 24
Modes "2560x1600" "2560x1440" "1920x1080"
EndSubSection
EndSection

重启,即可生效,此时,物理屏幕输出为黑屏

若要恢复有线屏幕输出,则删除该文件,重启

调整为任意分辨率

xrandr --fb 1280x960

Pastebin 在线剪贴板部署

https://github.com/Nugine/pastebin 加Star,赞

设置nginx代理

修改默认nginx配置文件default为

server {
listen 80;

server_name "pastebin";

gzip on;
gzip_comp_level 4;
gzip_types application/javascript text/css application/json;
gzip_vary on;
gzip_static on;

location / {
proxy_pass http://localhost:3000;
}

location /api/ {
proxy_pass http://localhost:8000;
}
}

启动后端

进入pastebin-server目录后

nohup cargo +nightly run &

需要 Nightly 工具链

启动前端

进入pastebin-front目录后

screen -dmS pastebin npm run dev

Rust 环境配置

使用rustup最优

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs  sh

如要使用NIGHTLY新功能

rustup toolchain install nightly
cargo +nightly run
0%