[GCP] 搭建 VPN 服务器 – 在线代理篇

区别与其它代理服务器,在线代理的优点在于不用安装额外的客户端以及配置就直接可以访问被墙的网络,但部分模块可能会无法加载出来,比如 xgeeky.com/proxy


定位到空间的根目录,新建一个文件夹 proxy
下载 proxy.zip 并解压到 proxy 文件夹下
# 新建文件夹并设置归属
sudo mkdir proxy & cd proxy
sudo chown www-data:www-data proxy
# 下载并解压proxy.zip
wget http://xgeeky.com/wp-content/uploads/2017/12/phproxy.zip
unzip phproxy.zip
# 设置归属
sudo chown www-data:www-data *

[1] [GCP] 搭建 VPN 服务器 – 创建虚拟机实例
[2] [GCP] 搭建 VPN 服务器 – Shadowsocks篇
[3] [GCP] 搭建 VPN 服务器 – IPsec VPN篇

[GCP] 搭建 VPN 服务器 – IPsec VPN篇

感谢 hwdsl2 的贡献,使得 IPsec VPN 的创建更加简单。

# 下载脚本
wget https://git.io/vpnsetup -O vpnsetup.sh
# 如果需要自定义用户名密码之类,可以先编辑脚本,将里面的YOUR_IPSEC_PSK, YOUR_USERNAME 以及 YOUR_PASSWORD的值替换成自己的,然后运行
nano -w vpnsetup.sh
# 运行脚本
sudo sh vpnsetup.sh


[1] [GCP] 搭建 VPN 服务器 – 创建虚拟机实例
[2] [GCP] 搭建 VPN 服务器 – Shadowsocks篇
[3] [GCP] 搭建 VPN 服务器 – 在线代理篇

[1] hwdsl2 – setup-ipsec-vpn

[GCP] 搭建 VPN 服务器 – Shadowsocks篇


# 更新系统
sudo apt-get update
# 安装 pip
sudo curl -O sudo apt-get install python-pip
# 使用pip 安装 Shadowsocks
sudo pip install shadowsocks
sudo nano /etc/shadowsocks.json

进入编辑器后复制以下内容,记得替换密码 “mypassword” 成你的密码,之后按 Ctrl+o 保存,Ctrl+x 退出。

    "local_address": "",
    "fast_open": false
# 新建脚本
sudo nano /etc/init.d/shadowsocks

进入编辑器后复制以下内容,之后按 Ctrl+o 保存,Ctrl+x 退出。

# Provides:          shadowsocks
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: start shadowsocks 
# Description:       start shadowsocks

    ssserver -c /etc/shadowsocks.json -d start

    ssserver -c /etc/shadowsocks.json -d stop

case "$1" in
    echo "Usage: $0 {start|reload|stop}"
    exit 1
# 修改权限
sudo chmod +x /etc/init.d/shadowsocks
# 添加 开机启动
sudo update-rc.d shadowsocks defaults
# 启动 服务
sudo service shadowsocks start


[1] [GCP] 搭建 VPN 服务器 – 创建虚拟机实例
[2] [GCP] 搭建 VPN 服务器 – IPsec VPN篇
[3] [GCP] 搭建 VPN 服务器 – 在线代理篇

[1] 用Google Cloud Platform搭建Shadowsocks服务教程
[2] 设置 shadowsocks server 开机启动

[GCP] 搭建 VPN 服务器 – 创建虚拟机实例

在gcp上(谷歌云)上设置一个vpn服务器可能是最爽的事情了。基于google 1年的免费额,你可以在gcp上创建一个专属vpn私服,甚至可以做到流畅1080p的YouTube播放。

1 端口映射
转到 “VPC Network – Firewall rule” 并添加一下防火墙规则,即允许所有端口。

2 创建虚拟机实例
转到 “Compute Engine – VM instances” 并创建一个实例,参数可以按照一下选择:
Name (名称): 随意
Zone (区域): 选择 asia-east1-a
Machine type (机器类型): micro 即可,一个共享cpu,600mb 内存
Boot disk (启动盘): 选择 Debian 8
Firewall (防火墙): 勾上允许HTTP以及HTTPS
展开选项卡,选择 Networking (网络) – External IP (外网IP): 这里我们需要选择创建一个IP并分配给该虚拟机。这样这个虚拟机才能被外网访问到。


[1] [GCP] 搭建 VPN 服务器 – Shadowsocks篇
[2] [GCP] 搭建 VPN 服务器 – IPsec VPN篇
[3] [GCP] 搭建 VPN 服务器 – 在线代理篇

[GCP] Run tensorflow with GPU on Google Cloud Platform

To create a VM instance, you have to register on the Google cloud platform, and once you registered, you will get a 300$ free trial. I won’t include the registration part here as it is very easy.

1 External IP addresses
Navigate to “VPC Network – External IP addresses” and apply for a new static IP and name it as you want
The result will look like this, in this case, i named it to taiwan as i choose from asia areas:

2 Firewall rules
Navigate to “VPC Network – Firewall rule” and add a firewall rule like this:

3 Apply an API to use GPUs
You have to choose a right area as some areas do not provide GPU usage and the price could be various. In this case, we choose “asia-east1-a” and decide to use its Tesla P100
Navigate to “IAM & admin – Quotas” and select the API you want to apply, you will receive an email from Google, then the follow the instructions to use the GPU you want (usually, just click the link provided in the email).

4 Create an instance
Navigate to “Compute Engine – VM instances” and create an vm instance.
In order to the use GPU we applied, you have to choose the same area.
Hit the “Customize” button and customize your machine type, then expand the GPU section to use a P100.
For the operating system, just choose Ubuntu 16, you can also use an SSD or expand the boot disk size to 20 GB if you like.
For the Firewall section, just tick both the HTTP and HTTPS traffic.
You may also have to expand the next section and configure your network interface to use static IP (optional).
Do not be afraid of the price as Google will only charge you from the 300$ when you are running the device and it is charged by minutes.

5 CUDA® Toolkit 8.0.
Once you have created the instance, click SSH button to open an SSH console and follow the following commands.

sudo apt-get update
sudo curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
sudo dpkg -i ./cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda-8-0 -y

6 cuDNN v6 for CUDA 8.0
We have to use the Jupyter Notebook to upload our installation package first. To do this, you can click this link and download one. Remeber, you have to create a NVIDIA account if do not have one. Then, agree terms and choose the following one to download, which is the “cuDNN v6.0 Library for Linux”.

# The file name could be different, be careful.
# Download the cudnn package with wget. You can get the download link when you are downlowning a cudnn file.
wget https://...../cudnn-8.0-linux-x64-v6.0.tgz.xxxxxxxxxxx
# Rename the file
mv cudnn-8.0-linux-x64-v6.0.tgz.xxxxxxxxxxx cudnn-8.0-linux-x64-v6.0.tgz
# Unzip the file and install cudnn
tar -xzvf cudnn-8.0-linux-x64-v6.0.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
# Edit .bashrc
nano ~/.bashrc
# Add the following two lines to the file
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda
# Press Ctrl+O to save changes and Ctrl+X to exit the editor
# Update changes
source ~/.bashrc

7 Tensorflow

sudo pip3 install tensorflow-gpu

Now you can have fun with your VM instance.
To save your 300$, do not to forget to shutdown your VM instance after using it.