k8s部署mitmproxy多台代理服务器

Posted dounine

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了k8s部署mitmproxy多台代理服务器相关的知识,希望对你有一定的参考价值。

不能使用k8s yaml方式直接使用,目前还不清楚是什么原因引到的
Dockerfile

FROM mitmproxy/mitmproxy:latest
EXPOSE 8080
EXPOSE 8081
ENV TZ=Asia/Shanghai
CMD ["mitmweb","--web-host","0.0.0.0","--set","ssl_insecure=true","--set","block_global=false"]

打包

docker build . -t dounine/mitmproxy:latest

下面的共享目录,是为了共享证书,这样所有客户端只要导入一个证书,就可以使用所有代理服务器了
deploy.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: proxy-pv-nas
  labels:
    pv: proxy
spec:
  capacity:
    storage: 10Gi
  storageClassName: nas
  persistentVolumeReclaimPolicy: Retain
  accessModes:
    - ReadWriteMany
  flexVolume:
    driver: "alicloud/nas"
    options:
      server: "xxxxx.cn-hangzhou.nas.aliyuncs.com"
      path: "/test_log/.mitmproxy"
      vers: "3"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: proxy-pvc-nas
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: nas
  resources:
    requests:
      storage: 10G
  selector:
    matchLabels:
      pv: proxy
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: proxy
  labels:
    app: proxy
spec:
  replicas: 1
  selector:
    matchLabels:
      app: proxy
  template:
    metadata:
      labels:
        app: proxy
      annotations:
        k8s.aliyun.com/eci-use-specs: "ecs.c5.large"
        k8s.aliyun.com/eci-spot-strategy: "SpotAsPriceGo"
        k8s.aliyun.com/eci-with-eip: "true"
    spec:
      hostNetwork: true
      volumes:
        - name: my-pvc-nas
          persistentVolumeClaim:
            claimName: proxy-pvc-nas
      containers:
        - name: proxy
          image: dounine/mitmproxy:latest
          volumeMounts:
            - name: my-pvc-nas
              mountPath: "/home/mitmproxy/.mitmproxy"
          ports:
            - containerPort: 8080
              name: http
              protocol: TCP
            - containerPort: 8081
              name: https
              protocol: TCP

直接暴露pod端口对外直接使用,可在ECI那里查看IP地扯

export http_proxy=http://xxxxx:8080
export https_proxy=http://xxxxx:8080

以上是关于k8s部署mitmproxy多台代理服务器的主要内容,如果未能解决你的问题,请参考以下文章

k8s部署mitmproxy多台代理服务器

k8s部署mitmproxy多台代理服务器

Mitmproxy代理设置和证书安装

解决爬虫们的大部分障碍——mitmproxy使用初探

[转]使用 mitmproxy + python 做拦截代理

MITMProxy如何配置二次代理