安装

官网

Debian

mkdir -p ~/.gnupg && chmod 700 ~/.gnupg

Install the prerequisites:

curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor | tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
gpg --dry-run --quiet --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/debian $(lsb_release -cs) nginx" | tee /etc/apt/sources.list.d/nginx.list

安装

apt update
apt install nginx

安装好后删除list

rm -rf /etc/apt/sources.list.d/nginx.list

配置

启动:

service nginx start

守护:

systemctl enable nginx
systemctl start nginx
systemctl restart nginx
systemctl stop nginx
systemctl disable nginx

配置文件

程序配置文件:/etc/nginx/nginx.conf
默认配置文件:/etc/nginx/conf.d/default.conf
配置文件目录:/etc/nginx/conf.d/

如果要用反代:
/etc/nginx/nginx.conf文件的http字段加入:

map $http_upgrade $connection_upgrade {
default upgrade;
''      close;
}

缓存路径:
'/var/cache/nginx'

log缓存路径
'/var/log/nginx'

反代CF

反代CF会出现502,
增加以下配置:

proxy_ssl_name $host;
proxy_ssl_server_name on;

如果不是同一个域名那么$host改成反代域名

最后修改:2026 年 05 月 23 日 02 : 43 PM