跳至主要内容

利用Azure Web App免费计划部署V2Ray服务端

V2Ray作为一款极其强大的工具软件,不仅可以在VPS上部署,还可以在各种PaaS上建立服务端。

目前已知的免费平台有:

  • Heroku    (Container,free)
  • Openshift(Container,free)
  • Bluemix   (Cloudfoundry Container,Credit Card Required)
  • Azure       (Web App,Microsoft Imagine)


对于Heroku和Openshift,部署方式都是通过docker容器,优点是镜像构建非常灵活,高度可定制。

Bluemix的Cloudfoundry支持原生docker,提供root权限,扩展性要比上述两者更为强大。
缺点是自带的mybluemix.net域名被墙,但是ip正常,因此可通过修改hosts实现直连

Azure指的是Microsoft Imagine的免费订阅,本文不介绍获取此订阅的路子。

Azure Web App理论上也支持docker容器部署,但是是收费项目,在Microsoft Imagine订阅里不可用,因此本文讨论的是利用Go编译出的Windows可执行exe直接部署,全程傻瓜式操作。


教程开始:

第一步,新建一个免费的Web App

第二步,在Web App的应用程序设置界面打开websocket支持

第三步,上传V2Ray程序至wwwroot
可在Github的V2Ray项目Release页面找到。理论上Web App是32位Windows环境,但是亲测64位的V2Ray.exe也是可以用的,此处推荐用32位的版本

第四步,把v2ray.exe重命名为azureapp.exe
Web App只会执行该命名的Go程序

第五步,修改config.json
端口设置为环境变量HTTP_PLATFORM_PORT

参考配置:
{
  "log": {
    "loglevel": "warning"
    },
  "inbound": {
    "port": "env:HTTP_PLATFORM_PORT",
    "listen": "0.0.0.0",
    "protocol": "vmess",
    "settings": {
    "clients": [
          {
          "id": "YOUR UUID IS HERE",
          "level": 1,
          "alterId": 64
          }
       ]
    },
    "streamSettings": {
        "network": "ws"
        }
    },
    "outbound": {
        "protocol": "freedom",
        "settings": {},
        "tag": "direct"
        },
    "policy": {
    "levels": {
        "0": {"uplinkOnly": 0}
        }
    }
}

第六步,在wwwroot目录下新建一个文件web.config
内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
        </handlers>
        <!-- For Go webapp, we always generate azureapp.exe in wwwroot -->
        <httpPlatform processPath="D:\home\site\wwwroot\azureapp.exe" startupTimeLimit="60">
        </httpPlatform>
    </system.webServer>
</configuration>

第七步,打开网站主页
显示Bad Request即为正常运行

测试一下速度,好吧就算是香港节点也有点慢...

完结撒花



评论