有没有办法让预配置的 OpenVPN-AS 连接客户端(服务器锁定配置文件)在反向代理后面工作?

有没有办法让预配置的 OpenVPN-AS 连接客户端(服务器锁定配置文件)在反向代理后面工作?

问题

我们在 1 个公共 IP 上托管多项服务:

  • OpenVPN 访问服务器(vpn.ourdomain.com)
  • OpenVPN 社区版 (old-vpn.ourdomain.com)
  • Nginx 网络服务器 (subdomain.ourdomain.com)

为了使这一切与我们唯一的公共 IP 一起工作,我们使用 Nginx 反向代理服务器。这对于我们手动分发证书的 Web 服务和 OpenVPN 来说效果很好,但可从中下载的“预配置 OpenVPN 连接客户端”无法使用Openvpn AS CWS随附的证书进行连接。当我user-locked profile从中手动下载OpenVPN AS CWS并将其插入连接客户端时,我能够连接。

我联系了 OpenVPN 并咨询了这个问题,他们是这样回复的:

the Nginx reverse proxy is the reason why the connection using a server-locked (bundled) profile fails.
In your configuration, Nginx performs SSL offload and corrupt TLS verification between OpenVPN Connect client and Access Server.

You can try to publish port TCP 443 from the Access Server and stop Nginx to verify that when AS is available directly your users can connect.

在我询问是否有解决办法后,我得到了这样的答复:

OpenVPN Access Server is not developed to be placed behind the reverse proxy. It should be able to handle TLS session from OpenVPN client in order to authenticate them.
If you place As behind a proxy you will loose possibility to use server-locked profiles, only user-locked and autologin profiles can be used in this case.

当我正确理解这一点时(经过一些额外的研究),Nginx 代理会负责 SSL 连接,而该连接实际上应该由 来处理OpenVPN AS


尝试过的解决方案

我无法想象这在技术上是不可能的,即使它没有得到 OpenVPN 的官方支持,我还是使用了我的朋友 Google 并尝试了以下方法:

1

我认为我可以通过将vpn.ourdomain.com加密的流量传递给来“简单地”解决这个问题OpenVPN AS,并尝试了non terminating TLS pass throughhttps://gist.github.com/kekru/c09dbab5e78bf76402966b13fa72b9d2)。我无法将其与其他服务的“正常反向代理”结合使用,因此我决定设置一个测试代理服务器来测试此解决方案是否可能解决我的问题。

我能够正常non terminating TLS pass through proxy工作(我可以访问vpn.ourdomain.com,但根据浏览器,这是一个不安全的连接)。不幸的是,我仍然无法使用包含证书/配置的连接客户端进行连接。当我直接将其暴露给它时,OpenVPN ASvpn.ourdomain.com工作正常。

2

在一个较早的主题中 (https://forums.openvpn.net/viewtopic.php?t=27291) 我读到有人遇到类似问题,并注意到连接OpenVPN connect client到解析的 IPvpn.ourdomain.com而不是域。这意味着代理永远不会将这些调用转发到正确的服务器。作为肮脏的工作,他 (McSanz) 将所有流量转发到,这/RPC2对我们来说OpenVPN AS也可能是一种可行的解决方法,因为我们目前没有具有这种路径的应用程序。我也试过了(结合使用和不使用 1)


Nginx 配置

default reverse proxy我尝试过的(使用 TLS 终止)是:

server {
  listen        443 ssl;
  server_name   vpn.ourdomain.com "RPC2" "^rpc2$";   # tried with and without "RPC2" "^rpc2$"

  ssl_certificate /etc/nginx/ssl/_.ourdomain.com/_.ourdomain.com.chained.crt;
  ssl_certificate_key /etc/nginx/ssl/_.ourdomain.com/_.ourdomain.com.key;
  ssl_client_certificate /etc/nginx/ssl/_.ourdomain.com/_.ourdomain.com.ca;
  ssl_verify_client optional;

  location / {
    proxy_pass https://10.128.20.5:443;

    # app1 reverse proxy follow
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

  access_log /var/log/nginx/access_log.log;
  error_log /var/log/nginx/error_log.log;
}

我尝试过的流non terminating TLS pass through看起来像这样:

stream {
   map $ssl_preread_server_name $targetBackend {
     vpn.ourdomain.com openvpnas;
     "^rpc2&" openvpnas;
   }

    upstream openvpnas {
      server 10.128.20.5:443;      # This is the OpenVPN AS IP
    }

   server {
     listen 443;

     proxy_connect_timeout 1s;
     proxy_timeout 3s;
     resolver 1.1.1.1;         # No idea what this does, i tried with, without this line and with 8.8.8.8

     proxy_pass $targetBackend;   # i tried 10.128.20.5:443 here as wel
     ssl_preread on;
  }
}

include /etc/nginx/sites-enabled/*;请注意,我需要在http标签中注释掉nginx.conf并添加/etc/nginx/streams-enabled/*(流配置所在的位置)作为根标签nginx.conf以使流正常工作。这意味着在我测试流功能时,反向代理不再适用于所有其他服务。如果可以解决流配置的问题,我需要将其与我们托管的其他服务的默认反向代理功能并行运行。


问题

  • 即使 OpenVPN 不正式支持,是否可以让预配置的 OpenVPN AS 连接客户端与附带的配置一起工作?
  • 如果可以实现这一点,那么是否也可以使用 Nginx 作为反向代理,或者我们应该用另一个应用程序替换代理?
  • 如果可以使用 Nginx 作为反向代理,我做错了什么?

答案1

经过大量研究和与支持人员的无休止邮件往来,似乎无法在(Nginx)代理后面运行 OpenVPN AS。OpenVPN 本身不支持它,我找不到解决方法来让它(服务器锁定的配置文件)工作。它确实适用于用户锁定的配置文件(需要手动下载并添加到客户端)

这是使用 OpenVPN 发送无尽邮件的结果。也许有人有办法/破解它来利用这些信息。(答案来自使用 OpenVPN 发送的邮件):

the Nginx reverse proxy is the reason why the connection using a server-locked (bundled) profile fails.
In your configuration, Nginx performs SSL offload and corrupt TLS verification between OpenVPN Connect client and Access Server.

You can try to publish port TCP 443 from the Access Server and stop Nginx to verify that when AS is available directly your users can connect.

OpenVPN Access Server is not developed to be placed behind the reverse proxy. It should be able to handle TLS session from OpenVPN client in order to authenticate them.
If you place As behind a proxy you will loose possibility to use server-locked profiles, only server-locked and autologin profiles can be used in this case.

OpenVPN AS 服务器日志始终会打印此信息。不确定这是否会给这个答案增加一些内容,但也许对某些人有用。如果没有,也没什么坏处 ;-) : 在此处输入图片描述

相关内容