nginx常用

以下是为您整理出来关于【nginx常用】合集内容,如果觉得还不错,请帮忙转发推荐。

【nginx常用】技术教程文章

Nginx 配置文件简介-3(Nginx 常用模块)

ngx_http_geo_module ngx_http_geo_module模块使用取决于客户端IP地址的值创建变量。 语法:geo [$address] $variable { ... } 默认值:无 应用位置:http 作用:定义从指定的变量获取客户端的IP地址。默认情况下,nginx从$remote_addr变量取得客户端IP地址,但也可以从其他变量获得。 案例:geo $geo {default 0;127.0.0.1 2;192.168.1.0/24 1;10.1.0.0/16 1; } http {geo $arg_boy $ttlsa_com {default 0;127.0.0...

nginx 常用全局变量

变量 说明$args 请求中的参数,如www.123.com/1.php?a=1&b=2的$args就是a=1&b=2$content_length HTTP请求信息里的"Content-Length"$conten_type HTTP请求信息里的"Content-Type"$document_root nginx虚拟主机配置文件中的root参数对应的值$document_uri 当前请求中不包含指令的URI,如www.123.com/1.php?a=1&b=2的$document_uri就是1.php,不包含后面的参数$host 主机头,也就是域名$http_user_agent 客户端的详细信息,也就是浏览器...

nginx常用配置

对请求图片进行防盗链配置; location ~* \.(gif|jpg|png|swf|flv)$ { valid_referers none blocked www.xxx.com ; 配置白名单hostif ($invalid_referer) { return 403; } }针对图片目录进行防盗链配置; location /images/ { alias /data/images/; valid_referers none blocked server_names www.xxx.com ; 配置白名单host if ($invalid_referer) {return 403;} } 设置目录访问控制:location /directory_name/{ allow 12...

总结下Nginx常用的功能模块

nginx-1.10.3]# ./configure \ --prefix=/usr/local/nginx \ #指定安装路径 --user=nginx --group=nginx \ #指定用户名及组 --with-http_ssl_module #开启网站的ssl加密 --with-http_auth_basic_module #实现网站的用户认证 --with-http_charset_module #自定义网站编码,如UTF-8 --with-http_fastcgi_module #转发请求给PHP服务 --with-http_gzip_module #实现网站数据压...

22,Nginx常用功能模块【代码】【图】

1,Nginx常用模块(日志切割)1)我们可以在虚拟主机配置定义不同网站日志放到以自己名字命名的日志文件里2)systemctl reload nginxcd /var/log/nginx && ll 4)切割日志,让日志按照每天日期去命名5,logrotate -f /etc/logrotate.d/nginx 切割2,查看Nginx状态模块1)cd /etc/nginx/conf.d2)systemctl restart nginx3)curl www.oldzhang.comrequests:http请求数handled:连接成功数accepts:总的连接数3,目录索引模块像这样的目录索...

Nginx常用配置及优化安全

一个站点配置多个域名 server {listen 80;server_name demo.ct99.cn demo1.ct99.cn; } server_name 后跟多个域名即可,多个域名之间用空格分隔 一个服务配置多个站点 server {listen 80;server_name demo.ct99.cn;location / {root /home/project/pa;index index.html;} }server {listen 80;server_name demo1.ct99.cn;location / {root /home/project/pb;index index.html;} }server {listen 80;serve...

Nginx常用配置指令说明【代码】

Nginx常用配置指令说明 注意:局部作用域的配置指令可覆盖全局作用域的配置指令 1、不在http响应头中显示Nginx的版本# 可用于http{}配置块和server{}配置块server_tokens off;2、索引文件# 可用于http{}配置块和server{}配置块index index.html index.php;3、是否允许目录浏览# 可用于http{}配置块和server{}配置块autoindex on;4、设置网站根目录# 可用于http{}配置块和server{}配置块root "E:/nginx-1.12.2/html";5、设置http响...

nginx常用运维日志分析命令

nginx常用日志分析命令 运维人员必备常用日志分析命令1、总请求数 wc -l access.log |awk {print $1} 2、独立IP数 awk {print $1} access.log|sort |uniq |wc -l 3、每秒客户端请求数 TOP5 awk -F[ [] {print $5} access.log|sort|uniq -c|sort -rn|head -5 4、访问最频繁IP Top5 awk {print $1} access.log|sort |uniq -c | sort -rn |head -5 5、访问最频繁的URL TOP5 awk {print $7} access.log|sort |uniq -c | sort -rn |hea...

nginx常用配置

1/ 转发: upstream opossuperset_backend{ server 10.52.2.243:6666; keepalive 1000; } server{ location / {proxy_pass http://opossuperset_backend;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Real-IP $http_x_real_ip;}}

Nginx常用配置【代码】

常用代理Server配置: server {listen 80; //监听的本地端口server_name localhost; location /api1/ {proxy_pass http://localhost:8080; }# http://localhost/api1/xxx -> http://localhost:8080/api1/xxx;location /api2/ {proxy_pass http://localhost:8080/;}# http://localhost/api2/xxx -> http://localhost:8080/xxx; location /api3 {proxy_pass http://localhost:8080;}# http://loca...