Marco Nie - 2019年4月 https://blog.niekun.net/2019/04/ zh-CN you are the company you keep... Fri, 19 Apr 2019 10:22:00 +0800 Fri, 19 Apr 2019 10:22:00 +0800 chown 和 chmod 管理文件权限 https://blog.niekun.net/archives/224.html https://blog.niekun.net/archives/224.html Fri, 19 Apr 2019 10:22:00 +0800 admin Linux 的文件属性主要包含两部分:ownership 和 permission

一个文件或文件夹的属性包括:1.归属于某个 user 和 user group,2.在此 user 和 user group 下的读/写/执行权限及其他 user 的相关权限。分别通过 chown 和 chmod 来进行设置。

参考连接:
https://www.computerhope.com/unix/uchmod.htm
https://www.computerhope.com/unix/uchown.htm

chown

chown 修改文件或文件夹的 ownership。

ownership

Linux 是为多用户模式设计的,所以对于一个文件的操作对于不同的用户是不同的,这就是 permission。

主要有三种 permissions:

  • User permissions. These permissions apply to a single user who has special access to the file. This user is called the owner.
  • Group permissions. These apply to a single group of users who have access to the file. This group is the owning group.
  • Other permissions. These apply to every other user on the system. These users are known as others, or the world.

当一个文件创建的时候,当前登录用户就是这个文件的所有者,用户群就是当前用户所在的群。其他用户就是 other。

基本语法

chown user file
chown user:group file
chown -R user:group directory
  • 使用 -R 来设置一个文件夹及其内所有文件的权限。
  • 如果不需要设置 group,可以省略掉。

chmod

chmod 用来设置文件或文件夹的权限。

基本语法

chmod options permissions file

permission 有两种设置模式:符号和数字

符号:

  • 使用 u/g/o/a 表示用户/用户群/其他的用户/所有用户
  • 使用 r/w/x 设置读/写/执行权限

例如:

chmod u=rwx,g=rx,o=r myfile

表示 user 权限是:读写执行;group user 权限是:读执行;other 用户权限是:读

数字:

  • 使用 0~7 表示权限信息,转换成二进制模式三位数就代表:读/写/执行,例如 7 -> 111,表示:读写执行权限

    例如:
    chmod 754 myfile

表示 user 权限是:111读写执行;group user 权限是:101读执行;other 用户权限是:100读

option
常用的选项就是 -R 表示对文件夹及其内所有文件的设置。

权限的设置方法

可以使用运算符:+/-/= 来进行设置:

  • = 表示进行总体设置,如:u=rwx
  • + 表示增加某个权限,如:g+x
  • - 表示取消某个权限,如:o-w

如果运算符前没有指定用户,则默认代表全部用户 a。

查看文件权限设置

可以使用一下命令查看文件或文件夹的权限设置情况:

ls -l file

以上就是文件权限设置的简单应用。

]]>
0 https://blog.niekun.net/archives/224.html#comments https://blog.niekun.net/feed/archives/224.html
Linux 查看系统信息 https://blog.niekun.net/archives/223.html https://blog.niekun.net/archives/223.html Fri, 19 Apr 2019 09:28:00 +0800 admin free

显示当前内存使用情况,包括物理内存和 swap 虚拟内存

uptime

显示系统当前连续开机时间

top

实时显示系统运行信息,包括内存使用情况及进程信息。

df -h

硬盘可用容量信息

du

查看文件/文件夹空间占用

# 查看当前目录占用空间
du -sh

#查看特定目录占用空间
du -sh /home

pwd

当前目录信息

uname

系统版本信息 内核信息

]]>
0 https://blog.niekun.net/archives/223.html#comments https://blog.niekun.net/feed/archives/223.html
Windows 10 中文输入法特殊字符输入 https://blog.niekun.net/archives/217.html https://blog.niekun.net/archives/217.html Thu, 18 Apr 2019 15:42:00 +0800 admin 自从升级到 Windows 10 后一直在使用自带的中文输入法,主要还是考虑到安全和响应速度。在需要输入一些特殊字符的时候,其使用帮助没有太详细的指南,所以在查阅相关资料后,总结一下。

激活 U 和 V 模式

U 和 V 模式是用来输入中文相关特殊符号及内容的快捷键,当激活后就可以通过输入 V 或 U 键快速调用相关功能。

进入微软拼音设置项,在 advanced 栏内打开对应选项:
2019-04-18T07:30:01.png

打开后将输入法切换到微软拼音中文状态,开始输入快捷键测试。

U 模式

2019-04-18T07:32:40.png

  • 笔画:通过 h / p / s / n / z 按笔画搭建想要输入的文字,在不知道拼音的情况下有用
  • 拆分:通过输入文字的基本组成部分的拼音来输入最终文字,如:uererer -> 聶
  • 混合输入,可以将以上两种模式混合输入
  • 符号输入:特殊字符的输入,包括中文标点,数学标点等,通过提示快捷键进入选择,如:uubd -> 「引号」

V 模式

2019-04-18T07:39:46.png

主要将数字/日期/时间转换成中文模式。

  • 数字:将阿拉伯数字转换为中文,如:v123 -> 一百二十三
  • 日期:将数字日期转换为中文样式,如:v2016.01.10 -> 二〇一六年一月十日
  • 时间:输入数字时间转换,如:v12:20 -> 十二时二十分

常用快捷键:
CTRL + shift + B:输入 emoji 或颜文字
CTRL + shift + F:切换简体字/繁体字输入
win + v:显示历史剪贴板

]]>
0 https://blog.niekun.net/archives/217.html#comments https://blog.niekun.net/feed/archives/217.html
curl 使用教程 https://blog.niekun.net/archives/216.html https://blog.niekun.net/archives/216.html Thu, 18 Apr 2019 15:04:00 +0800 admin command line tool and library for transferring data with URLs

官网:https://curl.haxx.se/

everything curl: https://ec.haxx.se/

查看版本信息:

curl --version

verbose mode
当你使用过程中有任何错误,都可以使用 -v 来显示详细处理过程:

$ curl -v http://example.com -o saved
* Rebuilt URL to: http://example.com/
*   Trying 93.184.216.34...
...

下载文件

下载一个文件输出到 stdout:

curl http://example.com

保存远程文件本身的文件名:(--remote-name)

curl -O http://example.com/file.html

保存为特定文件名:(--output)

curl http://example.com -o output.html

下载 ftp 文件:

curl ftp://ftp.example.com/directory/
curl --user daniel:secret ftp://example.com/download

下载 sftp 文件:

curl sftp://example.com/file.zip -u user

下载 scp 文件:

curl scp://example.com/file.zip -u user

下载文件跳过 ssl 证书验证:

curl -k -O http://example.com/file.html

其他功能

修改请求头 HEAD 信息:

curl -H "Host: www.example.com" http://localhost/

设置 http/socks5 代理:

curl -x 192.168.0.1:8080 http:/example.com/
curl -x socks5://127.0.0.1:1080 http://www.example.com/
]]>
0 https://blog.niekun.net/archives/216.html#comments https://blog.niekun.net/feed/archives/216.html
安装 wordpress https://blog.niekun.net/archives/204.html https://blog.niekun.net/archives/204.html Tue, 09 Apr 2019 20:30:00 +0800 admin 最近想在试一下wordpress怎么样,于是尝试了下安装到服务器,期间在安装新版 php 和 在 Nginx 中使用 FastCGI 代理 php 上遇到一些麻烦的地方。

官网:https://wordpress.org

环境要求:

  • Nginx
  • PHP version 7.3 or greater.
  • MySQL version 5.6 or greater OR MariaDB version 10.0 or greater.
  • HTTPS support

这里需要安装 php7.3 和 MySQL5.6 以上版本,于是首先安装这两个。

Linux系统:ubantu14.04

Nginx

安装 Nginx 参考:https://niekun.net/archives/30.html
初始配置 Nginx 参考:https://niekun.net/archives/6.html

nginx 配置文件中,将 user 改为 www-data:

user  www-data;

php7.3

由于官方的源里没有 php7.3 版的程序,所以有两种方法安装:源码编译或添加第三方源。

我首先尝试了第一种方法,这里是官方参考手册:https://www.php.net/manual/zh/install.unix.nginx.php

但我在 make test 的时候遇到错误了,所以无法继续进行下去,在没找到错误原因的情况下,我尝试使用第二种方法。

添加第三方软件源:

由于第三方源是没有安全保证的,容易安装恶意软件,所以一定要找到值得信任的来源。

我使用的是这个:https://launchpad.net/~ondrej/+archive/ubuntu/php

开始添加源及安装 php:

add-apt-repository ppa:ondrej/php
apt-get update
apt-get install php7.3-fpm php7.3-mysql

安装完成后修改配置文件 php.ini,可以使用 find / -name php.ini 找到这个文件路径:

vim /etc/php/7.3/fpm/php.ini

通过搜索 /cgi.fix_pathinfo 找到下面字符串,去掉前面注释并修改:

cgi.fix_pathinfo=0

找到配置文件 www.conf:

vim /etc/php/7.3/fpm/pool.d/www.conf

Nginx 的执行用户是 www-data, 所以修改下面内容:

listen.owner = www-data
listen.group = www-data

重启 php-fpm 服务:

service php7.3-fpm restart

安装MySQL5.6

安装:

apt-get install mysql-server-5.7

期间会自动创建 root 用户根据提示设置密码。

启动 MySQL 服务:

service mysql start

查看当前 MySQL 版本:

mysql -V

进入 MySQL:

mysql -uUSER -pPASSWORD

创建数据库并设置权限:

create database blog; 
grant all privileges on blog.* to "root"@"localhost" identified by "password"; 
show databases;
quit;

*注意如果是在 Windows WSL 上安装,安装完成后不会提示设置账号密码,直接输入 sudo mysql 就进入 MySQL 了,建立新 user 和 database 指令如下:

create user "newuser"@"localhost" identified by "PASSWORD";
grant all privileges on *.* to 'newuser'@'localhost';
FLUSH PRIVILEGES;
create database wordpress;
grant all privileges on wordpress.* to "newuser"@"localhost" identified by "PASSWORD";
FLUSH PRIVILEGES;

WSL 中建立 database 建立 user 只能在 root 用户下,也就是 sudo mysql 进入的用户,然后授予其他自己建立的 user 使用 database 的权限。

数据库基本操作参考:https://niekun.net/index.php/archives/23.html

Nginx 配置 FastCGI

FastCGI proxying within Nginx is generally used to translate client requests for an application server that does not or should not handle client requests directly. FastCGI is a protocol based on the earlier CGI, or common gateway interface, protocol meant to improve performance by not running each request as a separate process. It is used to efficiently interface with a server that processes requests for dynamic content.

One of the main use-cases of FastCGI proxying within Nginx is for PHP processing. Unlike Apache, which can handle PHP processing directly with the use of the mod_php module, Nginx must rely on a separate PHP processor to handle PHP requests. Most often, this processing is handled with php-fpm, a PHP processor that has been extensively tested to work with Nginx.

简单说就是 FastCGI 实现了使用 Nginx 代理 php 请求的过程。

关于 FastCGI 的详细分析:https://www.digitalocean.com/community/tutorials/understanding-and-implementing-fastcgi-proxying-in-nginx
wordpress 官方对于配置 Nginx 的介绍,可设置多个网站的配置:https://codex.wordpress.org/Nginx

在 Nginx 配置文件内添加或修改如下片段:

include index.php;

location ~ [^/]\.php(/|$) {
    try_files $fastcgi_script_name =404;
    fastcgi_split_path_info ^(.+?\.php)(.*)$;
    fastcgi_pass unix:/run/php/php7.3-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}
  • location 里使用正则定义了匹配包含 php 后缀的 url。
  • try_files 用来拒绝非本地 php 文件的访问,$fastcgi_script_name 用来只识别 php 文件之前的路径,如果用 $uri 的话回到这访问二级路径 404。
  • fastcgi_split_path_info 用来将 请求 url 拆分成两部分:php 文件之前的 $fastcgi_script_name 和之后的部分:$fastcgi_path_info
  • fastcgi_pass 定义真正的用来处理 FastCGI 代理的服务,一般默认地址为:127.0.0.1:9000,可自定义指定为特定版本的php
  • fastcgi_param 定义一些需要的 FastCGI 变量值,大部分已经在 Nginx 安装是附带的 fastcgi_params 预定义好了。

测试及重新加载 Nginx 配置:

service nginx configtest
service nginx reload

在 root 目录新建 test.php 测试文件:

<?php
    phpinfo();
?>

访问:yourdomain/test.php,如果显示 php 信息页面,则代表 FastCGI 配置完成。

如果显示access denied可能是权限问题:

nginx 和php-fpm不再一个用户下运行,查看上面的说到的配置(默认都是www-data)

ps -aux | grep nginx
ps -aux | grep php

网站目录权限不对:

chmod -R 755 /www/path
chown -R www-data /www/path

以上就完成基本 php + mysql + nginx 的环境配置。

安装 wordpress

发布地址:https://wordpress.org/download/releases/

下载最新版并解压:

wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz

复制目录到网站 root 目录:

mv wordpress /your/www/root

由于 Nginx 和 php 的用户都是 www-data,所以设置网站目录用户级别也为 www-data:

chown -R www-data:www-data /your/www/root

这时候访问域名就会进入 wordpress 引导界面。根据提示绑定 mysql 数据库及其他相关。


wordpress free 主题:
https://colorlib.com/wp/themes/
https://colorlib.com/wp/free-wordpress-themes/

]]>
0 https://blog.niekun.net/archives/204.html#comments https://blog.niekun.net/feed/archives/204.html
关于debian的apt/dpkg包管理相关 https://blog.niekun.net/archives/196.html https://blog.niekun.net/archives/196.html Mon, 08 Apr 2019 22:11:00 +0800 admin Debian 是一个致力于自由软件开发并宣扬自由软件基金会之理念的自愿者组织。Debian 计划创建于 1993 年。当时,Ian Murdock 发出一份公开信,邀请软件开发者们参与构建一个基于较新的 Linux 内核的完整而紧密的软件发行版。

官网:https://www.debian.org/

简单来说就是一个 Linux 的发行版,和 centos Ubuntu是一个类型的。但是其设计初衷为纯粹,更为干净。

APT(advanced package tool)

Debian 带来了数万个软件包。为了方便用户使用,这些软件包都已经被编译包装为一种方便的格式,开发人员把它叫做 deb 包。

Debian 系统中,软件包管理可由多种工具协作进行,范围从最底层的 dpkg 命令直到图形界面的 Synaptic 工具。推荐在 Debian 系统中管理软件包的标准工具是 apt 工具集。

使用 apt 安装软件,就不需要从源码开始编译了,可以有效节省时间。

有两个主要命令:
apt-get:用于安装,升级或清理软件包
apt-cache:用户寻找新的软件包

apt-get

更新软件包元数据:

apt-get update

升级所有已安装包:

apt-get upgrade

或者:

apt-get dist-upgrade

升级特定软件包:

apt-get upgrade <package_name>

upgrade 和 dist-upgrade 的区别:

upgrade 是一个更安全的模式,它不会尝试删除现有或安装一个新的软件包,而 dist-upgrade 会更加“聪明”的替你安装包,这个过程可能会删除或更改你现有的软件包,包括一些你不想进行更改的包,有潜在隐患。

所以进行一次完整的升级:

apt-get update && sudo apt-get upgrade -y

安装一个软件包:

apt-get install <package_name>

重新安装一个已安装的软件包:

apt-get install --reinstall <package_name>

同时安装多个包:

apt-get install <package_1> <package_2> <package_3>

安装一个包的特定版本:

apt-get install <package_name>=<version_number>

删除一个包:

apt-get remove <package_name>

或者:

apt-get purge <package_name>

apt-get remove 和 apt-get purge 的区别:

remove 只会删除这个包本身,不会删除其配置文件等残留内容,这意味着如果你重新安装此包,会提示你要覆盖相关配置文件。purge 会删除此包的相关所有内容。

清理本地缓存仓库文件:

apt-get clean

清理本地过期缓存文件:

apt-get autoclean

删除之前自动安装的不再需要的包:

apt-get autoremove

安装其他包管理源:(注意不要添加不被信任的源,以免危险)

add-apt-repository ppa:<some/source>
apt-get update

如果添加一个第三方源后,执行 apt-get update 时提示:GPG error: http://ppa.launchpad.net trusty InRelease...
这时需要先确定其 key 没有问题,这个可以访问这个源发布者页面查看其 key 比对命令行里出现的 key,如果一样的话需要手动加入 key 到 key管理器:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <PUBKEY>

<PUBKEY> 替换为 key。

删除自己安装的某个包管理源,可以安装 ppa-purge 来管理:

apt-get install ppa-purge
ppa-purge ppa:<some/source>
apt-get update

已安装的第三方源在 /etc/apt/sources.list.d/ 目录下的 .list 文件。

手动删除 .list 文件也可删除对应源,删除后执行 apt-get update

apt-cache

搜索你想要的软件:

apt-cache search <search term>

你不需要精确的包名字,它会自动匹配相近的内容。

如果你知道确切的包名来搜索,可以这样:

apt-cache pkgnames <search_term>

或者更精确的搜索到一个包的详细;

apt-cache showpkg <package_name>

sources.list

List of configured APT data sources

包管理数据源列表文件地址:/etc/apt/sources.list/etc/apt/sources.list.d/ 目录下的所有 .list 文件。

在 sources.list.d 下添加源文件,等同于使用上面的 add-apt-repository 命令。

list 格式解释参考:http://manpages.ubuntu.com/manpages/trusty/man5/sources.list.5.html

官方源列表:https://launchpad.net/ubuntu/+archivemirrors

unoffical php: https://launchpad.net/~ondrej/+archive/ubuntu/php
unoffical ffmpeg源:https://launchpad.net/~mc3man/+archive/ubuntu/trusty-media

dpkg

dpkg 是基于 Debian 的 Linux 系统的包管理器,它可以 安装,删除,创建包,不同于 apt 等其他包管理器,它不可以自动的安装一些依赖文件。所有的安装操作都需要手动完成。

apt 也是 dpkg 安装包形式的。所以 dpkg 可以管理 apt 安装的包

常用命令:

列出当前系统安装的所有包:

dpkg -l

列出特定包的相关安装信息:

dpkg -l | grep xxxx

列出安装某个包时创建的文件:

dpkg -L nginx

查看某个文件是在那个包安装时创建的:

dpkg -S file

dpkg -S /etc/nginx/naxsi.rules
nginx-common: /etc/nginx/naxsi.rules

安装一个 deb 包:

dpkg -i xxx.deb

删除一个包:

dpkg -r nginx
或者
dpkg -p nginx





]]>
0 https://blog.niekun.net/archives/196.html#comments https://blog.niekun.net/feed/archives/196.html
NGINX rewrite 模块的应用 https://blog.niekun.net/archives/195.html https://blog.niekun.net/archives/195.html Thu, 04 Apr 2019 22:44:00 +0800 admin nginx rewrite 模块主要应用于修改客户端发起的 url 请求,主要使用场景有两个:
1.客户端请求的域名已经已经有了新的地址,需要自动将连接进行转换
2.需要根据请求的 url 动态处理到不同的页面,此处主要使用 try_files 指令

指令有三种:return, rewrite, and try_files

return

这是最简单也最推荐使用的指令,主要应用于将指定的 server 或 location 重定向到另一个固定的 server 或 location。

一个简单的例子,将客户端请求重定向到新的域名:

server {
    listen 80;
    listen 443 ssl;
    server_name www.old-name.com;
    return 301 $scheme://www.new-name.com$request_uri;
}

示例参数解释:
301: Moved Permanently
$scheme: protocol (http or https)
$request_uri: 域名后的整个 url

关于状态码的使用参考:https://niekun.net/index.php/archives/192.html

重定向到新 url 的基本语法:

return (301 | 302 | 303 | 307) url;

也可以将一个字符串作为一个响应:

return (1xx | 2xx | 4xx | 5xx) ["text"];

例如:

return 401 "Access denied because token is expired or invalid";

return 执行后,在浏览器中会看到跳转到新的链接。

rewrite

此指令主要应用于一些更复杂的重定向,可以使用正则表达式进行匹配。此方式可以做动态链接的伪静态处理,隐藏 url 里的 index.php 等。

语法:

rewrite regex replacement [flag];

如果正则规则匹配到了请求的 uri,则会用 replacement 部分替换请求的 uri。rewrite 指令是按顺序执行的,也就是在一个快中可以写多个 rewrite 指令。使用 flag 来设置 uri 修改后的动作。

如果 replacement 里包含有 http://, https://, $scheme 则处理结束并给客户端发送重定向响应,客户端会重新访问新的 uri。

支持的 flag 标记:

  • last:修改完成后,结束当前的 rewrite 指令,然后根据修改后新的地址匹配 location 进行处理。客户端看起来 uri 没有变化
  • break:修改完成后,结束当前的 rewrite 指令,继续顺序执行下面的指令。这时候 $uri 已更新。
  • redirect:修改完成后,返回一个临时的 302 重新向给客户端,使用场景是 replacement 部分没有写:http://, https://, $scheme
  • permanent:修改完成后,返回一个 301 永久重定向响应给客户端。客户端跳转到新的 url
location /rewrite {
    rewrite ^(.*)$  /echo last;
  # rewrite ^(.*)$  /echo permanent;
    rewrite ^(.*)$  https://niekun.net last;
}

上面三个示例:

用 regex 时,使用小括号()来设置 group,按照顺序 group 用 $1,$2...表示。

以下是一个例子,进行了如下处理:

  • 以 /download 为起始然后包含 /media/ 或 /audio/ 段的 url 替换成包含 /mp3/ 段然后添加后缀 .mp3 或 .ra。
  • 例如:/download/cdn-west/media/file1 会修改为:/download/cdn-west/mp3/file1.mp3。
  • last:表示当处理完当前 rewrite 后跳过当前 server 或 location内其他的 rewrite 模块,为处理后的 url 寻找到合适的匹配的 location。
  • 如果没有匹配到,则返回状态码:402。

    server {
      # ...
      rewrite ^(/download/.*)/media/(\w+)\.?.*$ $1/mp3/$2.mp3 last;
      rewrite ^(/download/.*)/audio/(\w+)\.?.*$ $1/mp3/$2.ra  last;
      return  403;
      # ...
    }

try_files

此指令的参数为一个或多个文件或目录,以及一个最终内部 url。

语法:

try_files file ... uri;

处理过程为:nginx 检查列出的文件或文件夹地址是否存在,如果没有存在的话就内部重定向到指定的 url。为了让其工作,需要再定义一个 location 块捕获内部重定向的地址。

try_files 指令常用的变量为 $uri, 代表域名后的 url 部分。

以下例子进行了如下处理:

  • 放置一个 default.gif 文件来处理请求的图片不存在的情况
  • 如果请求 url 为:http://www.domain.com/images/image1.gif,nginx 首先寻找此 location 下 root 目录的 image1.gif 文件,如果没找到则再次寻找 image1.gif/ 目录,如果还是没有则重定向到 /images/default.gif,这次请求就完成了,此文件会缓存 30s
location /images/ {
    try_files $uri $uri/ /images/default.gif;
}

location = /images/default.gif {
    expires 30s;
}

参考链接

ngx_http_rewrite_module
https://www.nginx.com/blog/creating-nginx-rewrite-rules/

]]>
0 https://blog.niekun.net/archives/195.html#comments https://blog.niekun.net/feed/archives/195.html
HTTP/1.1 状态码定义 https://blog.niekun.net/archives/192.html https://blog.niekun.net/archives/192.html Thu, 04 Apr 2019 21:42:00 +0800 admin 常用状态码:

200 OK                        //客户端请求成功
301 Moved Permanently         //重定向到新的 URL
400 Bad Request               //客户端请求有语法错误,不能被服务器所理解
401 Unauthorized              //请求未经授权,这个状态代码必须和WWW-Authenticate报头域一起使用 
403 Forbidden                 //服务器收到请求,但是拒绝提供服务
404 Not Found                 //请求资源不存在,eg:输入了错误的URL
500 Internal Server Error     //服务器发生不可预期的错误
503 Server Unavailable        //服务器当前不能处理客户端的请求,一段时间后可能恢复正常

此文摘抄自:https://www.w3.org/Protocols/rfc2616/rfc2616.html

10 Status Code Definitions

Each Status-Code is described below, including a description of which method(s) it can follow and any metainformation required in the response.

10.1 Informational 1xx

This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty line. There are no required headers for this class of status code. Since HTTP/1.0 did not define any 1xx status codes, servers MUST NOT send a 1xx response to an HTTP/1.0 client except under experimental conditions.

A client MUST be prepared to accept one or more 1xx status responses prior to a regular response, even if the client does not expect a 100 (Continue) status message. Unexpected 1xx status responses MAY be ignored by a user agent.

Proxies MUST forward 1xx responses, unless the connection between the proxy and its client has been closed, or unless the proxy itself requested the generation of the 1xx response. (For example, if a

proxy adds a "Expect: 100-continue" field when it forwards a request, then it need not forward the corresponding 100 (Continue) response(s).)

10.1.1 100 Continue

The client SHOULD continue with its request. This interim response is used to inform the client that the initial part of the request has been received and has not yet been rejected by the server. The client SHOULD continue by sending the remainder of the request or, if the request has already been completed, ignore this response. The server MUST send a final response after the request has been completed. See section 8.2.3 for detailed discussion of the use and handling of this status code.

10.1.2 101 Switching Protocols

The server understands and is willing to comply with the client's request, via the Upgrade message header field (section 14.42), for a change in the application protocol being used on this connection. The server will switch protocols to those defined by the response's Upgrade header field immediately after the empty line which terminates the 101 response.

The protocol SHOULD be switched only when it is advantageous to do so. For example, switching to a newer version of HTTP is advantageous over older versions, and switching to a real-time, synchronous protocol might be advantageous when delivering resources that use such features.

10.2 Successful 2xx

This class of status code indicates that the client's request was successfully received, understood, and accepted.

10.2.1 200 OK

The request has succeeded. The information returned with the response is dependent on the method used in the request, for example:

GET an entity corresponding to the requested resource is sent in the response;

HEAD the entity-header fields corresponding to the requested resource are sent in the response without any message-body;

POST an entity describing or containing the result of the action;

TRACE an entity containing the request message as received by the end server.

10.2.2 201 Created

The request has been fulfilled and resulted in a new resource being created. The newly created resource can be referenced by the URI(s) returned in the entity of the response, with the most specific URI for the resource given by a Location header field. The response SHOULD include an entity containing a list of resource characteristics and location(s) from which the user or user agent can choose the one most appropriate. The entity format is specified by the media type given in the Content-Type header field. The origin server MUST create the resource before returning the 201 status code. If the action cannot be carried out immediately, the server SHOULD respond with 202 (Accepted) response instead.

A 201 response MAY contain an ETag response header field indicating the current value of the entity tag for the requested variant just created, see section 14.19.

10.2.3 202 Accepted

The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place. There is no facility for re-sending a status code from an asynchronous operation such as this.

The 202 response is intentionally non-committal. Its purpose is to allow a server to accept a request for some other process (perhaps a batch-oriented process that is only run once per day) without requiring that the user agent's connection to the server persist until the process is completed. The entity returned with this response SHOULD include an indication of the request's current status and either a pointer to a status monitor or some estimate of when the user can expect the request to be fulfilled.

10.2.4 203 Non-Authoritative Information

The returned metainformation in the entity-header is not the definitive set as available from the origin server, but is gathered from a local or a third-party copy. The set presented MAY be a subset or superset of the original version. For example, including local annotation information about the resource might result in a superset of the metainformation known by the origin server. Use of this response code is not required and is only appropriate when the response would otherwise be 200 (OK).

10.2.5 204 No Content

The server has fulfilled the request but does not need to return an entity-body, and might want to return updated metainformation. The response MAY include new or updated metainformation in the form of entity-headers, which if present SHOULD be associated with the requested variant.

If the client is a user agent, it SHOULD NOT change its document view from that which caused the request to be sent. This response is primarily intended to allow input for actions to take place without causing a change to the user agent's active document view, although any new or updated metainformation SHOULD be applied to the document currently in the user agent's active view.

The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields.

10.2.6 205 Reset Content

The server has fulfilled the request and the user agent SHOULD reset the document view which caused the request to be sent. This response is primarily intended to allow input for actions to take place via user input, followed by a clearing of the form in which the input is given so that the user can easily initiate another input action. The response MUST NOT include an entity.

10.2.7 206 Partial Content

The server has fulfilled the partial GET request for the resource. The request MUST have included a Range header field (section 14.35) indicating the desired range, and MAY have included an If-Range header field (section 14.27) to make the request conditional.

The response MUST include the following header fields:

  - Either a Content-Range header field (section 14.16) indicating
    the range included with this response, or a multipart/byteranges
    Content-Type including Content-Range fields for each part. If a
    Content-Length header field is present in the response, its
    value MUST match the actual number of OCTETs transmitted in the
    message-body.
  - Date
  - ETag and/or Content-Location, if the header would have been sent
    in a 200 response to the same request
  - Expires, Cache-Control, and/or Vary, if the field-value might
    differ from that sent in any previous response for the same
    variant

If the 206 response is the result of an If-Range request that used a strong cache validator (see section 13.3.3), the response SHOULD NOT include other entity-headers. If the response is the result of an If-Range request that used a weak validator, the response MUST NOT include other entity-headers; this prevents inconsistencies between cached entity-bodies and updated headers. Otherwise, the response MUST include all of the entity-headers that would have been returned with a 200 (OK) response to the same request.

A cache MUST NOT combine a 206 response with other previously cached content if the ETag or Last-Modified headers do not match exactly, see 13.5.4.

A cache that does not support the Range and Content-Range headers MUST NOT cache 206 (Partial) responses.

10.3 Redirection 3xx

This class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request. The action required MAY be carried out by the user agent without interaction with the user if and only if the method used in the second request is GET or HEAD. A client SHOULD detect infinite redirection loops, since such loops generate network traffic for each redirection.

  Note: previous versions of this specification recommended a
  maximum of five redirections. Content developers should be aware
  that there might be clients that implement such a fixed
  limitation.

10.3.1 300 Multiple Choices

The requested resource corresponds to any one of a set of representations, each with its own specific location, and agent- driven negotiation information (section 12) is being provided so that the user (or user agent) can select a preferred representation and redirect its request to that location.

Unless it was a HEAD request, the response SHOULD include an entity containing a list of resource characteristics and location(s) from which the user or user agent can choose the one most appropriate. The entity format is specified by the media type given in the Content- Type header field. Depending upon the format and the capabilities of

the user agent, selection of the most appropriate choice MAY be performed automatically. However, this specification does not define any standard for such automatic selection.

If the server has a preferred choice of representation, it SHOULD include the specific URI for that representation in the Location field; user agents MAY use the Location field value for automatic redirection. This response is cacheable unless indicated otherwise.

10.3.2 301 Moved Permanently

The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise.

The new permanent URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).

If the 301 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

  Note: When automatically redirecting a POST request after
  receiving a 301 status code, some existing HTTP/1.0 user agents
  will erroneously change it into a GET request.

10.3.3 302 Found

The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.

The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).

If the 302 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

  Note: RFC 1945 and RFC 2068 specify that the client is not allowed
  to change the method on the redirected request.  However, most
  existing user agent implementations treat 302 as if it were a 303
  response, performing a GET on the Location field-value regardless
  of the original request method. The status codes 303 and 307 have
  been added for servers that wish to make unambiguously clear which
  kind of reaction is expected of the client.

10.3.4 303 See Other

The response to the request can be found under a different URI and SHOULD be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. The new URI is not a substitute reference for the originally requested resource. The 303 response MUST NOT be cached, but the response to the second (redirected) request might be cacheable.

The different URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).

  Note: Many pre-HTTP/1.1 user agents do not understand the 303
  status. When interoperability with such clients is a concern, the
  302 status code may be used instead, since most user agents react
  to a 302 response as described here for 303.

10.3.5 304 Not Modified

If the client has performed a conditional GET request and access is allowed, but the document has not been modified, the server SHOULD respond with this status code. The 304 response MUST NOT contain a message-body, and thus is always terminated by the first empty line after the header fields.

The response MUST include the following header fields:

  - Date, unless its omission is required by section 14.18.1

If a clockless origin server obeys these rules, and proxies and clients add their own Date to any response received without one (as already specified by [RFC 2068], section 14.19), caches will operate correctly.

  - ETag and/or Content-Location, if the header would have been sent
    in a 200 response to the same request
  - Expires, Cache-Control, and/or Vary, if the field-value might
    differ from that sent in any previous response for the same
    variant

If the conditional GET used a strong cache validator (see section 13.3.3), the response SHOULD NOT include other entity-headers. Otherwise (i.e., the conditional GET used a weak validator), the response MUST NOT include other entity-headers; this prevents inconsistencies between cached entity-bodies and updated headers.

If a 304 response indicates an entity not currently cached, then the cache MUST disregard the response and repeat the request without the conditional.

If a cache uses a received 304 response to update a cache entry, the cache MUST update the entry to reflect any new field values given in the response.

10.3.6 305 Use Proxy

The requested resource MUST be accessed through the proxy given by the Location field. The Location field gives the URI of the proxy. The recipient is expected to repeat this single request via the proxy. 305 responses MUST only be generated by origin servers.

  Note: RFC 2068 was not clear that 305 was intended to redirect a
  single request, and to be generated by origin servers only.  Not
  observing these limitations has significant security consequences.

10.3.7 306 (Unused)

The 306 status code was used in a previous version of the specification, is no longer used, and the code is reserved.

10.3.8 307 Temporary Redirect

The requested resource resides temporarily under a different URI. Since the redirection MAY be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.

The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s) , since many pre-HTTP/1.1 user agents do not understand the 307 status. Therefore, the note SHOULD contain the information necessary for a user to repeat the original request on the new URI.

If the 307 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

10.4 Client Error 4xx

The 4xx class of status code is intended for cases in which the client seems to have erred. Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable to any request method. User agents SHOULD display any included entity to the user.

If the client is sending data, a server implementation using TCP SHOULD be careful to ensure that the client acknowledges receipt of the packet(s) containing the response, before the server closes the input connection. If the client continues sending data to the server after the close, the server's TCP stack will send a reset packet to the client, which may erase the client's unacknowledged input buffers before they can be read and interpreted by the HTTP application.

10.4.1 400 Bad Request

The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.

10.4.2 401 Unauthorized

The request requires user authentication. The response MUST include a WWW-Authenticate header field (section 14.47) containing a challenge applicable to the requested resource. The client MAY repeat the request with a suitable Authorization header field (section 14.8). If the request already included Authorization credentials, then the 401 response indicates that authorization has been refused for those credentials. If the 401 response contains the same challenge as the prior response, and the user agent has already attempted authentication at least once, then the user SHOULD be presented the entity that was given in the response, since that entity might include relevant diagnostic information. HTTP access authentication is explained in "HTTP Authentication: Basic and Digest Access Authentication" [43].

10.4.3 402 Payment Required

This code is reserved for future use.

10.4.4 403 Forbidden

The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. If the server does not wish to make this information available to the client, the status code 404 (Not Found) can be used instead.

10.4.5 404 Not Found

The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.

10.4.6 405 Method Not Allowed

The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource.

10.4.7 406 Not Acceptable

The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.

Unless it was a HEAD request, the response SHOULD include an entity containing a list of available entity characteristics and location(s) from which the user or user agent can choose the one most appropriate. The entity format is specified by the media type given in the Content-Type header field. Depending upon the format and the capabilities of the user agent, selection of the most appropriate choice MAY be performed automatically. However, this specification does not define any standard for such automatic selection.

  Note: HTTP/1.1 servers are allowed to return responses which are
  not acceptable according to the accept headers sent in the
  request. In some cases, this may even be preferable to sending a
  406 response. User agents are encouraged to inspect the headers of
  an incoming response to determine if it is acceptable.

If the response could be unacceptable, a user agent SHOULD temporarily stop receipt of more data and query the user for a decision on further actions.

10.4.8 407 Proxy Authentication Required

This code is similar to 401 (Unauthorized), but indicates that the client must first authenticate itself with the proxy. The proxy MUST return a Proxy-Authenticate header field (section 14.33) containing a challenge applicable to the proxy for the requested resource. The client MAY repeat the request with a suitable Proxy-Authorization header field (section 14.34). HTTP access authentication is explained in "HTTP Authentication: Basic and Digest Access Authentication" [43].

10.4.9 408 Request Timeout

The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time.

10.4.10 409 Conflict

The request could not be completed due to a conflict with the current state of the resource. This code is only allowed in situations where it is expected that the user might be able to resolve the conflict and resubmit the request. The response body SHOULD include enough

information for the user to recognize the source of the conflict. Ideally, the response entity would include enough information for the user or user agent to fix the problem; however, that might not be possible and is not required.

Conflicts are most likely to occur in response to a PUT request. For example, if versioning were being used and the entity being PUT included changes to a resource which conflict with those made by an earlier (third-party) request, the server might use the 409 response to indicate that it can't complete the request. In this case, the response entity would likely contain a list of the differences between the two versions in a format defined by the response Content-Type.

10.4.11 410 Gone

The requested resource is no longer available at the server and no forwarding address is known. This condition is expected to be considered permanent. Clients with link editing capabilities SHOULD delete references to the Request-URI after user approval. If the server does not know, or has no facility to determine, whether or not the condition is permanent, the status code 404 (Not Found) SHOULD be used instead. This response is cacheable unless indicated otherwise.

The 410 response is primarily intended to assist the task of web maintenance by notifying the recipient that the resource is intentionally unavailable and that the server owners desire that remote links to that resource be removed. Such an event is common for limited-time, promotional services and for resources belonging to individuals no longer working at the server's site. It is not necessary to mark all permanently unavailable resources as "gone" or to keep the mark for any length of time -- that is left to the discretion of the server owner.

10.4.12 411 Length Required

The server refuses to accept the request without a defined Content- Length. The client MAY repeat the request if it adds a valid Content-Length header field containing the length of the message-body in the request message.

10.4.13 412 Precondition Failed

The precondition given in one or more of the request-header fields evaluated to false when it was tested on the server. This response code allows the client to place preconditions on the current resource metainformation (header field data) and thus prevent the requested method from being applied to a resource other than the one intended.

10.4.14 413 Request Entity Too Large

The server is refusing to process a request because the request entity is larger than the server is willing or able to process. The server MAY close the connection to prevent the client from continuing the request.

If the condition is temporary, the server SHOULD include a Retry- After header field to indicate that it is temporary and after what time the client MAY try again.

10.4.15 414 Request-URI Too Long

The server is refusing to service the request because the Request-URI is longer than the server is willing to interpret. This rare condition is only likely to occur when a client has improperly converted a POST request to a GET request with long query information, when the client has descended into a URI "black hole" of redirection (e.g., a redirected URI prefix that points to a suffix of itself), or when the server is under attack by a client attempting to exploit security holes present in some servers using fixed-length buffers for reading or manipulating the Request-URI.

10.4.16 415 Unsupported Media Type

The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.

10.4.17 416 Requested Range Not Satisfiable

A server SHOULD return a response with this status code if a request included a Range request-header field (section 14.35), and none of the range-specifier values in this field overlap the current extent of the selected resource, and the request did not include an If-Range request-header field. (For byte-ranges, this means that the first- byte-pos of all of the byte-range-spec values were greater than the current length of the selected resource.)

When this status code is returned for a byte-range request, the response SHOULD include a Content-Range entity-header field specifying the current length of the selected resource (see section 14.16). This response MUST NOT use the multipart/byteranges content- type.

10.4.18 417 Expectation Failed

The expectation given in an Expect request-header field (see section 14.20) could not be met by this server, or, if the server is a proxy, the server has unambiguous evidence that the request could not be met by the next-hop server.

10.5 Server Error 5xx

Response status codes beginning with the digit "5" indicate cases in which the server is aware that it has erred or is incapable of performing the request. Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. User agents SHOULD display any included entity to the user. These response codes are applicable to any request method.

10.5.1 500 Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request.

10.5.2 501 Not Implemented

The server does not support the functionality required to fulfill the request. This is the appropriate response when the server does not recognize the request method and is not capable of supporting it for any resource.

10.5.3 502 Bad Gateway

The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.

10.5.4 503 Service Unavailable

The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response.

  Note: The existence of the 503 status code does not imply that a
  server must use it when becoming overloaded. Some servers may wish
  to simply refuse the connection.

10.5.5 504 Gateway Timeout

The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.

  Note: Note to implementors: some deployed proxies are known to
  return 400 or 500 when DNS lookups time out.

10.5.6 505 HTTP Version Not Supported

The server does not support, or refuses to support, the HTTP protocol version that was used in the request message. The server is indicating that it is unable or unwilling to complete the request using the same major version as the client, as described in section 3.1, other than with this error message. The response SHOULD contain an entity describing why that version is not supported and what other protocols are supported by that server.

]]>
0 https://blog.niekun.net/archives/192.html#comments https://blog.niekun.net/feed/archives/192.html
使用Nginx配置强ssl的网站 https://blog.niekun.net/archives/187.html https://blog.niekun.net/archives/187.html Wed, 03 Apr 2019 23:24:00 +0800 admin 本文主要参考的网站:
https://cipherli.st
https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html

This tutorial shows you how to set up strong SSL security on the nginx webserver. We do this by updating OpenSSL to the latest version to mitigate attacks like Heartbleed, disabling SSL Compression and EXPORT ciphers to mitigate attacks like FREAK, CRIME and LogJAM, disabling SSLv3 and below because of vulnerabilities in the protocol and we will set up a strong ciphersuite that enables Forward Secrecy when possible. We also enable HSTS and HPKP. This way we have a strong and future proof ssl configuration and we get an A+ on the Qually Labs SSL Test.

本文使用的配置需要相关软件的最低版本要求:
Nginx: 1.13.0 -- 升级教程:https://niekun.net/index.php/archives/30.html
openssl: 1.0.1 -- 升级教程:https://niekun.net/index.php/archives/183.html

首先需要生成一个 4096 bit 的 DH parameters:

openssl dhparam -out /etc/nginx/your.domain/dhparam.pem 4096

编辑 Nginx 配置文件,在server段加入或修改如下:

ssl_protocols                TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers    on; 
ssl_ciphers                  ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
ssl_dhparam                  /etc/nginx/your.domain/dhparam.pem;
ssl_ecdh_curve               secp384r1;
ssl_session_timeout          10m;
ssl_session_cache            shared:SSL:10m;
ssl_session_tickets          off;
ssl_stapling                 on;
ssl_stapling_verify          on;
resolver                     8.8.8.8 1.1.1.1 valid=300s;
resolver_timeout             5s; 
add_header                   Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
add_header                   X-Frame-Options DENY;
add_header                   X-Content-Type-Options nosniff;
add_header                   X-XSS-Protection "1; mode=block";

ssl_ciphers 的设置可能会影响一些老版本系统或浏览器的访问,以下是兼容 IE6/WinXP 的配置:

EECDH+AESGCM:EDH+AESGCM:ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4;

修改完成后测试配置及重启:

service nginx configtest
service nginx reload
service nginx restart

可以在这里测试网站安全级别,最高为 A+: https://www.ssllabs.com/ssltest/index.html

]]>
0 https://blog.niekun.net/archives/187.html#comments https://blog.niekun.net/feed/archives/187.html
使网站支持http2 https://blog.niekun.net/archives/184.html https://blog.niekun.net/archives/184.html Wed, 03 Apr 2019 22:54:00 +0800 admin 这里使用的是 Nginx 做代理。

使用 http2 需要 openssl 的版本至少是 1.0.2。使用命令openssl version查看当前版本,如果太低,需要先升级 openssl。

升级教程:https://niekun.net/index.php/archives/30.html

在 Nginx 配置文件的 server 段内修改如下:

server {
    listen               443 ssl http2;
    listen               [::]:443 ssl http2;
    ...
}

实际就是在原有配置基础上,在 listen 内加入 http2 即可。

修改后测试及重新加载配置文件:

service nginx configtest
service nginx reload
]]>
0 https://blog.niekun.net/archives/184.html#comments https://blog.niekun.net/feed/archives/184.html