分类目录归档:未分类

Nginx代理隧道端口

# 建立隧道把对本地20001端口的访问通过host-a转发到127.0.0.1(即host-a)的443端口,如果127.0.0.1是别的地址,就是转发到host-a可以访问的另外一台主机
ssh -f -N -L 20001:127.0.0.1:443 root@host-a
如果需要绑定本机的特定IP,可以前面再加,0.0.0.0表示所有IP,也可以只写本机的某个IP
ssh -f -N -L 0.0.0.0:20001:127.0.0.1:443 root@host-a
接上述配置,当希望把本机的20001端口作为nginx的upstream发布为http/https服务时,报错502 bad gateway。查看nginx日志发现异常:
2024/12/24 17:30:17 [crit] 8786#8786: *20 connect() to 192.168.4.33:20001 failed (13: Permission denied) while connecting to upstream
经查询,是防火墙拦截了nginx的访问,加上相应的策略即可:
sestatus # 查询防火墙是否开启:1开启,0未开启
audit2allow -w -a  # 查看 SELinux 警告
audit2allow -M nginx_custom_policy -a  # 生成自定义的策略
semodule -i nginx_custom_policy.pp  # 安装该策略

老Mac电脑安装新操作系统及禁用更新

使用OpenCore-Patcher可以在老的Mac电脑上安装新操作系统。但是有点电脑太老了,安装最新的跑不动,可以安装次新的操作系统。这样老是会检测到新版本并小红点提示,很麻烦,可以禁用更新。

在系统设置-软件更新-自动更新,点右侧小图标,关闭相关更新即可。

关于小红点,可以使用以下代码禁止显示:
# 软件更新不扫描网上信息
softwareupdate -l --no-scan
# 清除系统设置角标
defaults write com.apple.systempreferences AttentionPrefBundleIDs 0
# 重启程序坞
killall Dock

# 其他人说的下面的方法,在新版本的MacOS已经不适用
# softwareupdate --ignore "macOS Catalina"

OpenCore-Patcher的官方说明(截止2024.12)
Noteworthy features of OpenCore Legacy Patcher:

  • Support for macOS Big Sur, Monterey, Ventura, Sonoma and Sequoia
  • Native Over the Air (OTA) System Updates
  • Supports Penryn and newer Macs
  • Full support for WPA Wi-Fi and Personal Hotspot on BCM943224 and newer wireless chipsets
  • System Integrity Protection, FileVault 2, .im4m Secure Boot and Vaulting
  • Recovery OS, Safe Mode and Single-user Mode booting on non-native OSes
  • Unlocks features such as Sidecar and AirPlay to Mac even on native Macs
  • Enables enhanced SATA and NVMe power management on non-Apple storage devices
  • Zero firmware patching required (ie. APFS ROM patching)
  • Graphics acceleration for both Metal and non-Metal GPUs