AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1041848
Accepted
CodeNinja
CodeNinja
Asked: 2020-11-10 07:08:06 +0800 CST2020-11-10 07:08:06 +0800 CST 2020-11-10 07:08:06 +0800 CST

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

  • 772

问题

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

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

为了使这一切都适用于我们的 1 个也是唯一的公共 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 through(https://gist.github.com/kekru/c09dbab5e78bf76402966b13fa72b9d2)来“简单地”解决这个问题。我无法将它与其他服务的“正常反向代理”结合使用,所以我决定设置一个测试代理服务器来测试这个解决方案是否可以解决我的问题。

我能够non terminating TLS pass through proxy正常工作(我可以访问vpn.ourdomain.com并且根据浏览器它是不安全的连接)。不幸的是,我仍然无法连接包含证书/配置的连接客户端。当我直接暴露它时OpenVPN AS,vpn.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 可以作为反向代理,我做错了什么?
openvpn ssl nginx reverse-proxy
  • 1 1 个回答
  • 1052 Views

1 个回答

  • Voted
  1. Best Answer
    CodeNinja
    2021-10-19T22:22:20+08:002021-10-19T22:22:20+08:00

    经过大量研究和无休止的邮件支持后,似乎不可能在(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 服务器日志总是打印这个。不确定它是否为这个答案添加了一些东西,但它可能对某人有用。如果没有,它不会受到伤害;-): 在此处输入图像描述

    • 0

相关问题

  • OpenVPN:在哪里生成私钥?

  • 将 iPhone 连接到 OpenVPN

  • OpenVPN 的 Linux IP 转发 - 正确的防火墙设置?

  • 最好的点对点 VPN?

  • 通过 VPN 使您的打印机可用的最佳方法是什么?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve