Skip to content

Instantly share code, notes, and snippets.

@vector4wang
Last active June 24, 2020 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vector4wang/97887721e1e581cf1f746d01413aeaea to your computer and use it in GitHub Desktop.
Save vector4wang/97887721e1e581cf1f746d01413aeaea to your computer and use it in GitHub Desktop.
[nginx笔记] #nginx
! Configuration File for keepalived
global_defs {
notification_email {
381347268@qq.com
}
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER # 设置主master和备份backup
interface ens33 # 需要绑定的网卡,通过ipconfig查看
virtual_router_id 51 # 主备唯一值 任意
priority 150 # 权重
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.1.110/24 dev ens33 label ens33:1
}
}

nginx 笔记

安装

https://www.jianshu.com/p/cfa60fdc03d1

基本命令

启动 nginx

停止 nginx -s stop

版本号 nginx -v

重加载 nginx -s reload

区别

rootalias的区别

location /a {
	alias|root   html;
	index  index.html index.htm;
	autoindex on;
}
  • 使用root,访问xxx/a的时候,会去html/a的目录下找(最终的路径包含location指定的/a)
  • 使用alias,访问xxx/a的时候,会去html/下找(最终的路径不包含location指定的/a)

场景

开启目录

server {                             
    listen 81;                       
    server_name localhost;           
                                     
    location / {                     
            root /data;              
            autoindex on;            
            autoindex_exact_size off;
            autoindex_localtime on;  
    }                                
                                     
}                                    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment