Ubuntu -nginx配置
Ubuntu -nginx配置
日志切割 testlog.sh
使用脚本切割 nginx 日志,脚本内容如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| --------------------------nginx.conf--------------------- server { listen 80; server_name test.com;
location / { root test.com; index index.html index.htm; } access_log logs/test.com.access.log main;
}
--------------------------testlog.sh---------------------
LOGPATH=/data/server/nginx-1.4.2/logs/test.com.access.log BASEPATH=/data/$(date -d yesterday +%Y%m)
mkdir -p $BASEPATH bak=$BASEPATH/$(date -d yesterday +%Y%m%d%H%M).test.com.access.log
mv $LOGPATH $bak touch $LOGPATH kill -USR1 cat /data/server/nginx-1.4.2/logs/nginx.pid
--------------------------------------------------
|

location 精准匹配,正则匹配
1 2 3 4
| Syntax: location [ = | ~ | ~* | ^~ ] uri { ... } location @name { ... } Default: — Context: server, location
|

location 模块
location 二级目录,忽略index.html
rewrite 重写
1 2 3 4 5
| location /h5cfsh { index index.html; root /usr/local/apache2/htdocs/cfsh/h5cfsh/dist/; rewrite ^(.*)$ /index.html break; }
|
rewrite 重写 Laravel 和 Vue 部署
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| server { listen 80; server_name demo.dafei.com; charset utf-8; root E:/web/laravel_demo/public/; index index.php index.html; location / { autoindex on; try_files $uri $uri/ /index.php?$query_string; } location ~ .+\.php($|/) { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } location /web { alias E:/web/vue_demo/dist/; index index.html; } }
|
rewrite 重写—代理
1 2 3 4
| location /api { proxy_pass http://127.0.0.1:8080/api; }
|
rewrite 重写 SpringBoot 和 Vue 部署
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| server { listen 80; server_name demo.fei.com; root "E:/self_web/git_dev/vue/zFei_vue/dist"; location / { try_files $uri $uri/ /index.html; index index.html index.htm; } location /api/ { proxy_pass http://127.0.0.1:8072/api/; } }
|
重写文件地址
1 2
| #场景描述 文件上传后再某个具体的访问地址下面,需要给代理访问到
|
1 2 3 4
| location /profile/ { proxy_pass http://127.0.0.1:8072/profile/; }
|
1 2 3 4 5
| location /profile/ { alias /home/ruoyi/uploadPath/; }
|
底部
没有了