###编译

./configure --prefix=. --sbin-path=nginx --conf-path=nginx.conf --pid-path=nginx.pid --lock-path=nginx.lock --error-log-path=stderr --http-log-path=access.log --http-client-body-temp-path=client_body_temp --http-proxy-temp-path=proxy_temp --user=nobody --group=users --with-threads --with-file-aio --with-http_ssl_module  --with-http_v2_module  --with-http_v3_module --with-http_realip_module --with-http_addition_module --with-http_dav_module  --with-http_flv_module  --with-http_gzip_static_module  --with-http_stub_status_module --with-mail --with-mail_ssl_module  --with-stream --with-stream_ssl_module
make && make install

配置

  • nginx 启动
  • nginx -t 查看配置
  • nginx -s reload 重启
  • nginx -s stop 关闭
  • nginx -V 查看模块

    禁止缓存

    location ~* \.(js|css|png|jpg|gif|webp)$ {
      add_header Cache-Control no-store;
    }

    防盗链

    location ~* \.(gif|jpg|png)$ {
      valid_referers none blocked 192.168.0.1;
      if ($invalid_referer) {
         rewrite ^/ http://$host/logo.png;
      }
    }

    显示目录

    autoindex on;
    autoindex_exact_size off;
    autoindex_localtime on;

    php配置

          listen       8000 ssl;
          server_name  localhost;
            root   /home/html;
           index  index.html index.htm index.php;
    location ~ \.php$ {
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include        fastcgi_params;
          }
    //配置ssl
    ssl_certificate      /root/nginx/localhost.pem;
        ssl_certificate_key  /root/nginx/localhostkey.pem;
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;
        ssl_ciphers  HIGH:!aNULL:!MD5;
         ssl_prefer_server_ciphers  on;

    openssl生成密码

sh -c "echo -n 'admin:' >> pwd"
sh -c "openssl passwd -apr1 >> pwd"
123456 生成内容  admin:$apr1$.SYLFc6u$uCNTvsdcaBzD/8ikf/TVe.

auth_basic "Restricted Content";
auth_basic_user_file C:/app/caddy/nginx/pwd;
}
作者:Yoby  创建时间:2024-09-12 09:44
最后编辑:Yoby  更新时间:2025-05-21 19:21
上一篇:
下一篇: