Nginx安装

docker安装nginx

Nginx 极简教程

在线阅读

本地创建ssl证书工具--mkcert

https://github.com/FiloSottile/mkcert

源码安装

git clone https://github.com/FiloSottile/mkcert && cd mkcert
go build -ldflags "-X main.Version=$(git describe --tags)"

创建证书示例

$ mkcert -install
Created a new local CA 💥
The local CA is now installed in the system trust store! ⚡️
The local CA is now installed in the Firefox trust store (requires browser restart)! 🦊

$ mkcert example.com "*.example.com" example.test localhost 127.0.0.1 ::1

Created a new certificate valid for the following names 📜
 - "example.com"
 - "*.example.com"
 - "example.test"
 - "localhost"
 - "127.0.0.1"
 - "::1"

The certificate is at "./example.com+5.pem" and the key at "./example.com+5-key.pem"

nginx配置证书

ssl_certificate /usr/local/etc/nginx/ssl/example.com+5.pem;
ssl_certificate_key /usr/local/etc/nginx/ssl/example.com+5-key.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES2

nginx配置重载

nginx -t && nginx -s reload

nginx配置pdf预览

server {
     listen    80;
     server_name  download.xxx.com;

     location ^~ /download {
         alias html/pdf/;

         autoindex on;
         autoindex_exact_size on;
         autoindex_localtime on;
         charset utf-8;
         if ($request_filename ~* ^.*?\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){
            add_header Content-Disposition: 'p_w_upload;';
         }
     }

}
Copyright © neet11 2022 all right reserved,powered by GitbookLatest modification time: 2022-11-09 18:15:27

results matching ""

    No results matching ""