Nginx报错如下
错误提示
1 2 3 4 5 6 7
| Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.keystealth.org * extras: linux.mirrors.es.net * updates: mirrors.oit.uci.edu No package nginx available. Error: Nothing to do
|
解决
先安装epel-release软件仓库
1
| sudo yum install epel-release
|
EPEL 是由 Fedora 社区维护的额外软件包仓库,为 CentOS 和 RHEL 等企业级 Linux 提供了大量的扩展软件包,这些软件包在默认的 CentOS 或 RHEL 官方仓库中通常不包含
清除缓存
确保它使用新的仓库配置
更新yum安装包
重新安装 nginx
Nginx反向代理
证书从阿里云/腾讯云下载
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| server { listen 80; server_name img.cxy-csx.top;
location /attachments { proxy_pass https://cdn.discordapp.com; proxy_set_header Host cdn.discordapp.com; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_http_version 1.1; proxy_buffering off; proxy_cache_bypass $http_upgrade; add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Headers' 'Content-Type,Content-Length,Authorization,Accept,X-Requested-With'; } }
server { listen 443 ssl; server_name img.cxy-csx.top;
ssl_certificate /mnt/img.cxy-csx.top.pem; ssl_certificate_key /mnt/img.cxy-csx.top.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on; location /attachments { proxy_pass https://cdn.discordapp.com; proxy_set_header Host cdn.discordapp.com; add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Headers' 'Content-Type,Content-Length,Authorization,Accept,X-Requested-With'; 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_ssl_verify off; proxy_ssl_server_name on; }
}
|
另外,http请求可以重定向到https
检查nginx配置文件
重载配置文件