官网
https://nginx.org/
yum安装
https://nginx.org/en/linux_packages.html#RHEL
To set up the yum repository, create the file named /etc/yum.repos.d/nginx.repo with the following contents:
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
To install nginx, run the following command:
sudo yum install nginx
模块使用方法:
ngx_http_autoindex_module模块学习
作用:
The ngx_http_autoindex_module module processes requests ending with the slash character (‘/’) and produces a directory listing. Usually a request is passed to the ngx_http_autoindex_module module when the ngx_http_index_module module cannot find an index file.
配置:
the ngx_http_index_module module cannot find an index file
request is passed to the ngx_http_autoindex_module module
server {
listen 80;
server_name blog.ljbb.com;
location / {
autoindex on;
root /html/blog;
}
}
ngx_http_access_module模块学习
作用:
The ngx_http_access_module module allows limiting access to certain client addresses.
配置:
location / {
deny 192.168.1.1;
allow 192.168.1.0/24;
allow 10.1.1.0/16;
allow 2001:0db8::/32;
deny all;
}
ngx_http_auth_basic_module模块学习
作用:
The ngx_http_auth_basic_module module allows limiting access to resources by validating the user name and password using the “HTTP Basic Authentication” protocol.
配置:
location / {
auth_basic "closed site";
auth_basic_user_file conf/htpasswd;
}
ngx_http_index_module模块学习
作用:
The ngx_http_index_module module processes requests ending with the slash character (‘/’). Such requests can also be processed by the ngx_http_autoindex_module and ngx_http_random_index_module modules.
配置:
location / {
index index.$geo.html index.html;
}