[TEMPLATE] Nginx configuration template (nginx.conf) (LNMP + SSL + CDN version)

worker_processes  auto;


events {
    worker_connections  10000;
}


http {
    limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  60;
    client_body_timeout 20s;
    client_header_timeout 10s;
    send_timeout 30s;


    server {
        listen       80;
        limit_req zone=one burst=5;
        server_name www.eternalcenter.com;
        return 301 https://eternalcenter.com$request_uri;
        }


    server {
        listen       80;
        limit_req zone=one burst=5;
        server_name eternalcenter.com;
        return 301 https://eternalcenter.com$request_uri;
        }


    server {
        listen       443 ssl;
        server_name www.eternalcenter.com;

        ssl_certificate      /etc/nginx/ssl/eternalcenter.com.crt;
        ssl_certificate_key  /etc/nginx/ssl/eternalcenter.com.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        if ($request_method !~ ^(GET|POST)$){
        return 444;
        }

        root /usr/share/nginx/html;
        index index.php index.html;

        location ~ ^/\.user\.ini {
        deny all;
        }

        location ~*\.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
        expires 30d;
        access_log off;
        try_files $uri =404;
        }

        location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param HTTP_HOST $http_host;
        }

        location ~* ^/(wp-login\.php|admin-ajax\.php|wp-admin|wp-json|wp-includes|wp-content/plugins|wp-content/themes|wp-content/uploads) {
        set $cache_control_policy "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
        set $pragma_policy "no-cache";
        set $expires_policy "0";
        add_header Cache-Control $cache_control_policy always;
        add_header Pragma $pragma_policy always;
        add_header Expires $expires_policy always;

        try_files $uri $uri/ /index.php?$query_string;
        }

        location / {
             return 302 $scheme://eternalcenter.com$request_uri;
        }

        error_page  404              /404.html;
    }


    server {
        listen       443 ssl;
        server_name eternalcenter.com;

        ssl_certificate      /etc/nginx/ssl/eternalcenter.com.crt;
        ssl_certificate_key  /etc/nginx/ssl/eternalcenter.com.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        if ($request_method !~ ^(GET|POST)$){
        return 444;
        }

        root /usr/share/nginx/html/;
        index index.php index.html index.htm;

        location ~ ^/\.user\.ini {
        deny all;
        }
    
        location ~*\.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
        expires 30d;
        access_log off;
        try_files $uri =404;
        }

        location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
            fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html/$fastcgi_script_name;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param HTTP_HOST $http_host;
        } 

        location ~ ^/index\.php$ {

        set $cache_control_policy "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
        set $pragma_policy "no-cache";
        set $expires_policy "0";

        add_header Cache-Control $cache_control_policy always;
        add_header Pragma $pragma_policy always;
        add_header Expires $expires_policy always;
        }

        location / {
        try_files $uri $uri/ /index.php?$query_string;
        }

        error_page  404              /404.html;
        }


    gzip on;
    gzip_min_length 1000;
    gzip_comp_level 4;

    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    client_header_buffer_size 1k;
    large_client_header_buffers 4 4k;

    open_file_cache max=2000 inactive=20s;
    open_file_cache_valid  60s;
    open_file_cache_min_uses 5;
    open_file_cache_errors off;

}

[步骤] 系统升级 (从 Fedora 42 升级到 Fedora 44)

步骤一:升级所有已安装的软件

# sudo dnf update

步骤二:安装 Fedora 升级软件

# sudo dnf install dnf-plugin-system-upgrade

步骤三:刷新所有现有版本的软件源

# sudo dnf upgrade --refresh

步骤四:下载升级所有所需的软件

# sudo dnf system-upgrade download --releasever=44

步骤五:重启并升级系统

# sudo dnf system-upgrade reboot

(注意:系统会重启,并在后台升级系统,这个步骤可能会持续很长一段时间,根据虚拟机的硬件性能而定)

[排错] 解决 DELL 物理服务器重启后在 BIOS 界面卡住并报错 “The system Configuration Check operation resulted in the following issue: Comm Error: Backplane 0.”

报错现象

DELL 物理服务器重启后在 BIOS 界面卡住并报错

报错代码

The system Configuration Check operation resulted in the following issue: Comm Error: Backplane 0.

解决方法

步骤一:升级系统 BIOS

(步骤略)

步骤二:重启物理服务器

(步骤略)

[排错] 解决系统启动后卡在 “A start job is running for /dev/mapper/…… (…… / no limit)”

报错代码案例

当系统启动时,系统会一直卡住,并在 console 口显示以下内容:

A start job is running for /dev/mapper/vg-lv_swap (...... / no limit)

案例原因分析

GRUB 参数 resume=/dev/mapper/vg-lv_swap 阻止了系统启动

解决方法

步骤一:重启系统

(步骤略)

步骤二:进入系统启动时的 GRUB 参数临时设置界面

当系统启动时出现内核列表时按下 “e” 键

步骤三:临时删除阻止系统启动的 GRUB 参数

在以 Linux 开头的这一行里删除以下内容:

...... resume=/dev/mapper/vg-lv_swap ......

(补充:这里以删除 GRUB 参数 resume=/dev/mapper/vg-lv_swap 为例)

步骤四:在临时删除阻止系统启动的 GRUB 参数后进入系统

同时按下 “ctrl” 键和 “x” 键

步骤五:使用 root 账号登陆系统

(步骤略)

步骤六:在系统里永久删除阻止系统启动的 GRUB 参数

# grubby --update-kernel ALL --remove-args "resume=/dev/mapper/vg-lv_swap"

(补充:这里以删除 GRUB 参数 resume=/dev/mapper/vg-lv_swap 为例)