首页 > 编程知识 正文

nginx配置文件的几大模块,NGINX 配置文件

时间:2023-05-05 11:39:04 阅读:236894 作者:873

nginx安装目录nginx变量nginx模块 http-auth模块

nginx安装目录 # Nginx日志轮转,用于 logrotate服务的日志切割/etc/logrotate.d/nginx# Nginx主配置文件/etc/nginx/etc/nginx/nginx.conf/etc/nginx/conf.d/etc/nginx/conf.d/default.conf# cgi配置相关,fastcgi配置/etc/nginx/fastcgi_params/etc/nginx/scgi_params/etc/nginx/uwsgi_params# 编码转换映射转化文件/etc/nginx/koi-utf/etc/nginx/koi-win/etc/nginx/win-utf# 设置http协议的Content-Type与扩展名对应关系/etc/nginx/mime.types# 用于配置出系统守护进程管理器管理方式/etc/sysconfig/nginx/etc/sysconfig/nginx-debug/usr/lib/systemd/system/nginx-debug.service/usr/lib/systemd/system/nginx.service# Nginx的模块目录/etc/nginx/modules/usr/lib64/nginx/modules# Nginx服务启动管理的终端命令/usr/sbin/nginx/usr/sbin/nginx-debug# Nginx的手册和帮助文件/usr/share/doc/nginx-1.12.2/usr/share/doc/nginx-1.12.2/COPYRIGHT/usr/share/man/man8/nginx.8.gz# Nginx的缓存目录/var/cache/nginx# Nginx的日志目录/var/log/nginx nginx变量 HTTP变量: 比如 $http_user_agent,$http_cookie等表示HTTP请求信息的变量。内置变量:$args, 请求中的参数;$content_length, HTTP请求信息里的"Content-Length";$content_type, 请求信息里的"Content-Type";$document_root, 针对当前请求的根路径设置值;$document_uri, 与$uri相同;$host, 请求信息中的"Host",如果请求中没有Host行,则等于设置的服务器名;$limit_rate, 对连接速率的限制;$request_method, 请求的方法,比如"GET"、"POST"等;$remote_addr, 客户端地址;$remote_port, 客户端端口号;$remote_user, 客户端用户名,认证用;$request_filename, 当前请求的文件路径名$request_body_file, ??$request_uri, 请求的URI,带参数;$query_string, 与$args相同;$scheme, 所用的协议,比如http或者是https,比如rewrite ^(.+)$ $scheme://example.com$1 redirect;$server_protocol, 请求的协议版本,"HTTP/1.0"或"HTTP/1.1";$server_addr, 服务器地址,如果没有用listen指明服务器地址,使用这个变量将发起一次系统调用以取得地址(造成资源浪费);$server_name, 请求到达的服务器名;$server_port, 请求到达的服务器端口号;$uri, 请求的URI,可能和最初的值有不同,比如经过重定向之类的。 nginx模块

nginx官方中文-模块

http-auth模块 linux操作 #安装htpasswd模块yum install httpd#到指定的目录cd /etc/nginx#生成auth_conf文件,用户名jehadhtpasswd -c ./auth_conf jehad#在文件中添加一个用户,不覆盖原来的htpasswd ./auth_conf jhcoder 下面是nginx配置 server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.html; } #匹配admin页面 只允许某ip访问(也可以反过来)原理是使用remote_addr,使用代理时准确性不高,使用frp也不行# location ~ ^/admin.html {# root /home/project/nginx-code;# deny all;# allow 113.87.88.143;# } location ~ ^/admin.html { root /home/project/nginx-code; auth_basic ".......输入密码哇........."; auth_basic_user_file /etc/nginx/auth_conf; }} 模块的局限性
1、用户信息和系统不能同步 2、操作管理机械解决方法
1、nginx+lua高效验证 2、nginx+ladp nginx-auth-ladp模块

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。