0%

SSH开启端口转发需要修改 /etc/ssh/sshd_config配置文件,将 GatewayPorts修改为yes

参数解释:

-f 后台执行ssh指令
-C 允许压缩数据
-N 不执行远程指令
-R 将远程主机(服务器)的某个端口转发到本地端指定机器的指定端口
-L 本地端口转发
-D 动态端口转发

简版:本地端口转发(相当于正向代理),本地监听16379端口,将16379端口的流量都转发给6379端口

1
ssh -fCNL *:16379:localhost:6379 localhost
阅读全文 »

Netbox CSV 导出中文乱码

解决办法

修改文件:./netbox/netbox/netbox/views/generic.py

修改内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 1. 在 import 语句后面添加一个新的类,重写父类 `TableExport`
...
class TableExport2(TableExport):
def response(self, filename=None):
response = HttpResponse(content_type="text/csv; charset=utf-8-sig")
if filename is not None:
response["Content-Disposition"] = 'attachment; filename="{}"'.format(filename)
response.write(self.export())
return response

# 2. 修改 export_table 方法(大约在文件 200 行左右)让其使用重写的类来实例化
class ObjectListView(ObjectPermissionRequiredMixin, View):
...
#
def export_table(self, table, columns=None):
...
exporter = TableExport2(
export_format=TableExport.CSV,
table=table,
exclude_columns=exclude_columns
)
...

修改文件后,重启 netbox 服务。如果是容器部署,重启 netbox-docker_netbox_1 容器(暴露端口的那个容器)。

解决过程记录

阅读全文 »

架构概览

zabbix_deploy

网络环境不宜说太多:四朵独立的云,中间通过防火墙隔离,需要搭建一套监控系统对全网的网络设备进行监控,通过 Zabbix Server + Proxy 分布式部署方式来实现。

版本选择

截止目前,Zabbix 已经发布了 6.0 pre-release,稳定版也已经来到了 5.4。

在生产环境部署时,为稳定起见,建议使用 Long-term support (LTS) 版本。

本次部署选用的是 Zabbix 5.0 LTS 版本。

版本及软件依赖

阅读全文 »

PUT 和POST 是 HTTP 的两个方法(Method),都可以用来向 HTTP 服务器提交数据。似乎用哪个都可以,但其实两者还是有本质的区别的。

网上关于两者区别的文章比较多,但有相当一部分绝对是误导人。所以这次特意查看了 RFC7231,来澄清二者的区别。

首先直接摘出 RFC7231 中的的部分关键原文:

The fundamental difference between the POST and PUT methods is highlighted by the different intent for the enclosed representation. The target resource in a POST request is intended to handle the enclosed representation according to the resource’s own semantics, whereas the enclosed representation in a PUT request is defined as replacing the state of the target resource. Hence, the intent of PUT is idempotent and visible to intermediaries, even though the exact effect is only known by the origin server.

Proper interpretation of a PUT request presumes that the user agent knows which target resource is desired. A service that selects a proper URI on behalf of the client, after receiving a state-changing request, SHOULD be implemented using the POST method rather than PUT.

上面这两段描述的关键词就是“idempotent”(幂等),理解了这个词就理解了二者的本质区别。下面就围绕这个词从以下几个角度分析 PUTPOST 的区别。

阅读全文 »