AirVPNをプロキシとして使用する方法
公開日:
AirVPNのVPNサーバをプロキシとして使用する方法を紹介します。
注意点として、スクレイピング用途でVPNを使用するとBANされる可能性が高いのでそのような使い方は避けましょう。
概要

AirVPNではVPNの接続方式としてOpenVPNとWireGuardの2つが提供されています。
WireGuardのVPNをプロキシとして提供するWireproxyというものがあるのでそれを使ってプロキシ化します。
手順
AirVPNからWireGuardの設定ファイルをダウンロード
AirVPNにアクセス -> Client Area -> Config Generatorにアクセス
Choose protocolsでWireguardを有効化。適当に使用したい国のサーバをチェックしてページ下部のgenerateを押す。

こんな感じのファイルがダウンロードされます。
Wireproxyのインストール
こちらを参考にコンパイルとインストールを行います。
https://github.com/whyvl/wireproxy?tab=readme-ov-file#build-instruction
ビルド後、以下のコマンドが通ればOKです。
wireproxy --version
設定ファイルの用意
proxy.confというファイルにこのような設定を書きます。
WGConfig = wg0.conf
[Socks5]
BindAddress = 0.0.0.0:1080
[http]
BindAddress = 0.0.0.0:1081
先程ダウンロードしたAirVPNの設定ファイルをwg0.confに改名します。
wireproxy -c proxy.conf
起動します。
curlコマンドでproxy無しと有りでipが変わっていれば成功です。
curl ifconfig.io # proxy無し
curl -x "http://127.0.0.1:1081" ifconfig.io # proxy有り
curl -x "sock5://127.0.0.1:1080" ifconfig.io
おまけ: Docker化
wireproxyをDocker化します。AirVPNはdeviceの設定を適切に行うとVPNを5デバイスまで同時使用することが出来ます。なので、docker化することで数台分のproxyサーバを用意することが出来ます。
WGConfig = /etc/wireguard/wg0.conf
[Socks5]
BindAddress = 0.0.0.0:1080
[http]
BindAddress = 0.0.0.0:1081
Dockerfile
FROM golang:1.22.1-bookworm AS builder
RUN apt update && apt install git
WORKDIR /srv
RUN git clone --branch prefix https://github.com/corkborg/wireproxy.git && cd wireproxy && make
FROM ubuntu:22.04 AS app
RUN apt-get update && apt-get install -y iproute2 wireguard openssh-client curl openresolv git
COPY --from=builder /srv/wireproxy/wireproxy /srv/wireproxy
RUN install /srv/wireproxy /usr/local/bin
WORKDIR /srv
CMD wireproxy -c proxy.conf
compse.yaml
services:
device1:
build: .
volumes:
- ./conf/AirVPN_Japan_UDP-1637-Entry3.conf:/etc/wireguard/wg0.conf
- ./conf/proxy.conf:/srv/proxy.conf
ports:
- 1111:1181
restart: always
device2:
build: .
volumes:
- ./conf/AirVPN_United-States_UDP-1637-Entry3.conf:/etc/wireguard/wg0.conf
- ./conf/proxy.conf:/srv/proxy.conf
ports:
- 1112:1181
restart: always
curl -x "http://127.0.0.1:1111" ifconfig.io
curl -x "http://127.0.0.1:1112" ifconfig.io
更新日: