通过自定义域名访问内网的 Web 服务

通过简单配置 HTTP 类型的代理,您可以让用户通过自定义域名访问内网的 Web 服务。

HTTP 类型的代理非常适合将内网的 Web 服务通过自定义域名提供给外部用户。相比于 TCP 类型代理,HTTP 代理不仅可以复用端口,还提供了基于 HTTP 协议的许多功能。

HTTPS 与此类似,但是需要注意,frp 的 https 代理需要本地服务是 HTTPS 服务,frps 端不会做 TLS 终止。也可以结合 https2http 插件来实现将本地的 HTTP 服务以 HTTPS 协议暴露出去。

步骤

  1. 配置 frps.toml

    在 frps.toml 文件中添加以下内容,以指定 HTTP 请求的监听端口为 8080:

    bindPort = 7000
          vhostHTTPPort = 8080
          

    如果需要配置 HTTPS 代理,还需要设置 vhostHTTPSPort

  2. 配置 frpc.toml

    在 frpc.toml 文件中添加以下内容,确保设置了正确的服务器 IP 地址、本地 Web 服务监听端口和自定义域名:

    serverAddr = "x.x.x.x"
          serverPort = 7000
          
          [[proxies]]
          name = "web"
          type = "http"
          localPort = 80
          customDomains = ["www.yourdomain.com"]
          
          [[proxies]]
          name = "web2"
          type = "http"
          localPort = 8080
          customDomains = ["www.yourdomain2.com"]
          
  3. 启动 frps 和 frpc

  4. 域名解析

    www.yourdomain.comwww.yourdomain2.com 的域名 A 记录解析到服务器的 IP 地址 x.x.x.x。如果服务器已经有对应的域名,您还可以将 CNAME 记录解析到原始域名。另外,通过修改 HTTP 请求的 Host 字段也可以实现相同的效果。

  5. 通过浏览器访问

    使用浏览器访问 http://www.yourdomain.com:8080 即可访问内网机器上的 80 端口服务,访问 http://www.yourdomain2.com:8080 可以访问内网机器上的 8080 端口服务。

最后修改 November 15, 2023: fix 404 (#71) (626ce4d)

Access the Web service of the intranet through a custom domain name

By using a simple Configuration HTTP type Agent, you can enable users to access The Web service of the intranet through a custom domain name.

HTTP type agents are very suitable for integrating the web of internal networks Services are provided to external users through custom domain names. Compared to TCP type Agent, HTTP Agents not only reuse ports, but also provide many functions based on the HTTP protocol.

HTTPS is similar to this, but it should be noted that the HTTPS Agent for frp The local service needs to be an HTTPS service, and the FRPS end will not perform TLS termination. It can also be combined with Implementing HTTPS to convert local HTTP services The agreement was exposed.

Steps

  1. Configuration frps.toml

    Add the following to the frps.toml file to specify HTTP. The listening port for the request is 8080:

    bindPort = 7000
          vhostHTTPPort = 8080
          

    If you need Configuration HTTPS Agent, you also need to set the vhostHTTPSPort

  2. Configuration frpc.toml

    Add the following to the frpc.toml file to ensure that the correct server IP is set. Address, local Web service listening port and custom domain name:

    serverAddr = "x.x.x.x"
          serverPort = 7000
          
          [[proxies]]
          name = "web"
          type = "http"
          localPort = 80
          customDomains = ["www.yourdomain.com"]
          
          [[proxies]]
          name = "web2"
          type = "http"
          localPort = 8080
          customDomains = ["www.yourdomain2.com"]
          
  3. Start FRPS and FRPC

  4. Domain name resolution

    Connectwww.yourdomain. comand Domain name A forwww.yourdomain2. com Record the IP address resolved to the server x.x.x.x. If the server already has a corresponding domain name, you can also add CNAME Record resolution to the original domain name. Additionally, by modifying the Host of HTTP requests Fields can also achieve the same effect.

  5. Accessing through a browser

    Use browser access http://www.yourdomain.com:8080 You can access the 80 port service on the internal network machine to access http://www.yourdomain2.com:8080 You can access the 8080 port service on the internal network machine.

Last modified November 15, 2023: fix 404 (#71) (626ce4d)