nginx转发规则location中的/

Nginx转发用于将原始请求转发到新的地址对应的请求,一般可用于二级域名转发或子路径转发以及静态资源转发等等。在转发的location节点下proxy_pass配置中,目标地址末尾是否有 / 有很大影响。以下通过模糊匹配的方式分几类情况进行对比: 1 原始访问地址 假设原始访问地址为:http://abc.com/log/test。在nginx中,针对子路径/log/配置转发,实现该子路径下的所有请求都转到另一个应用中进行处理。 2 请求转发 注:转发相关配置中只取了proxy_pass部分,其他部分根据需要配置。 2.1 目标地址为根路径含/ 原始访问地址为:http://abc.com/log/test location /log/ { proxy_pass http://127.0.0.1:81/; } 实际请求地址为:http://127.0.0.1:81/test 最终效果:proxy_pass配置值替换掉原始请求地址中到location规则结尾部分 2.2 目标地址为根路径不含/ 原始访问地址为:http://abc.com/log/test location /log/ { proxy_pass http://127.0.0.1:81; } 实际请求地址为:http://127.0.0.1:81/log/test 最终效果:host及端口替换 2.3 目标地址为子路径含/ 原始访问地址为:http://abc.com/log/test location /log/ { proxy_pass http://127.0.0.1:81/sub/; } 实际请求地址为:http://127.0.0.1:81/sub/test 最终效果:proxy_pass配置值替换掉原始请求地址中到location规则结尾部分 2.4 目标地址为子路径不含/ 原始访问地址为:http://abc.com/log/test location /log/ { proxy_pass http://127.0.0.1:81/sub; } 实际请求地址为:http://127.0.0.1:81/subtest 最终效果:proxy_pass配置值替换掉原始请求地址中到location规则结尾部分 https://blog.csdn.net/lxh_worldpeace/article/details/108974025

Fix apt-get update “the following signatures couldn’t be verified because the public key is not available”

There are times when running apt-get update in Ubuntu will result in error messages such as the following:

[chris@server ~]$ sudo apt-get update
Ign http://security.ubuntu.com trusty-security InRelease
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
...
Fetched 21.9 MB in 14s (1,537 kB/s)
Reading package lists... Done
W: GPG error: http://security.ubuntu.com trusty-security Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
W: GPG error: http://archive.canonical.com trusty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
W: GPG error: http://archive.ubuntu.com trusty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
W: GPG error: http://archive.ubuntu.com trusty-updates Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
[chris@server ~]$

If these errors aren’t fixed, apt will have problems when installing or upgrading packages. For example:

[chris@server ~]$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree... Done
Calculating upgrade... Done
...
E: Some packages could not be authenticated
[chris@server ~]$

The apt packaging system has a set of trusted keys that determine whether a package can be authenticated and therefore trusted to be installed on the system. Sometimes the system does not have all the keys it needs and runs into this issue. Fortunately, there is a quick fix. Each key that is listed as missing needs to be added to the apt key manager so that it can authenticate the packages.

Looking at the error above, apt is telling us that the following keys are missing: 40976EAF437D05B5 and 3B4FE6ACC0B21F32. Notice that these are listed multiple times. Each unique key will only need to be added once.

Read more

简单搭建 Zerotier Moon 为虚拟网络加速

Zerotier 是一款开源工具,可以用来构建点对点(P2P)虚拟网络。比如你的女友不让你去网吧玩游戏,这时候你就可以建立一个 Zerotier 点对点虚拟网络,把你和朋友的家的电脑都加入到这个虚拟网络中,然后你们就可以像在网吧里一样联机玩耍了。

Zerotier 的基本用法可以参考NAS之旅第10期视频,这里我们要分享的是如何自己搭建 Zerotier Moon,加速 Zerotier-One 的连接,让虚拟网络更稳定的运行。

Read more

linux screen的用法

linux screen的用法

大家在初次接触linuxVPS时,会发现linux操作和windows操作太不相同的,windows都是图形操作界面,而linux一般是命令行操作,当然,linux也有图形操作界面,但是我们在将vps作为网络生产环境时,安装图形界面不光费时费力,更费vps那少的可怜的系统资源,所以,还是命令行吧,可是命令行只有一个,linux下编译命令一般执行也比较慢,如编译军哥的lnmp,少则半小时二十分钟,多则三小时五小时,一旦断开,正在编译的软件也就完了,这很不符合偶们的折腾精神,难道就木有个解决方法?当然有,那就是screen。

一、神马是screen?

Screen是一个可以在多个进程之间多路复用一个物理终端的全屏窗口管理器。Screen中有会话的概念,用户可以在一个会话中创建多个screen窗口,在每一个screen窗口中就像操作一个真实的telnet/SSH连接窗口那样。

通俗的讲,screen命令用于新建一个或多个“命令行窗口”,在新建的这“窗口”中,可以执行命令;每个“窗口”都是独立并行的。

Read more

Openwrt路由通过Zerotier组网实现异地内网互访

最近有三地组网需求,使相互能内网访问。此方案还可以通过OpenVPN来实现,本文只记录一下本次使用的Zerotier方案。

关于Zerotier方案的优缺点,阅读本文的同学自行搜索一下,此处不做赘述了。

本方案以Openwrt 18.06-RC2为例子做说明,其他版本理论类似,有需求的同学自己实验即可。

至于怎么注册zerotier账户,此处也不做说明。

Zerotier地址:https://my.zerotier.com/

Read more

Ubuntu/GNOME 一些好用的扩展

shell扩展

需先安装有gnome-tweak。

可在 https://extensions.gnome.org/ 中下载安装.注册该网站,浏览器会提示安装相应扩展。

archlinux可以在aur中搜索gnome-shell-extension的关键字查找(以”插件名+shell“进行搜索,如yaourt weather shell)。

一些扩展(部分扩展在gnome-shell-extensions这个包里面):

Read more

[Howto] Use wayland with propietary nvidia drivers

Wayland does not play well with proprietary drivers. Currently the biggest issue is that nvidia does currently not support Xwayland properly, so apps that require it get software rendering. This includes most games, which are the most common use case for proprietary nvidia drivers. This is why gnome automatically disables Wayland if you have nvidia. … Read more