【问题标题】:nginx proxy URl failingnginx 代理 URL 失败
【发布时间】:2019-06-23 05:40:24
【问题描述】:

我想在私有网络前托管一个 Nginx 代理,所有私有客户端用户都可以通过代理服务器与特定 URL 对话。但是,一旦它连接 URL,就会发生身份验证重定向,并且那个时候 URl 发生了变化,并且由于我的专用网络没有任何方法可以连接其他 URL [互联网被阻止],因此它正在超时。有人可以分享一些想法来解决这个问题吗?

我在下面粘贴了我的配置

server {
        listen 0.0.0.0:443 ssl;
        server_name    k8s.cluster.mstsg.com;
        ssl_certificate /var/tmp/omni/fullchain.pem ;
        ssl_certificate_key /var/tmp/omni/privkey.pem ;
        ssl_ciphers         EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;
        ssl_protocols        TLSv1.2;
        error_log    error.log debug;




        location /{
           proxy_pass https://ms-tsg.cp.cloud;
           proxy_ssl_server_name on;
           proxy_set_header Host ms-tsg.cp.cloud;
           proxy_ssl_server_name on;
        }

a) 客户端将访问代理服务器的 url k8s.cluster.mstsg.com b) 然后将其转发到“https://ms-tsg.cp.cloud”,然后重定向到另一个 URL“https://auth-tsg.cp.cloud”进行身份验证。 c) 身份验证重定向期间浏览器将失败,原因是我的客户端只能访问代理,并且当标头中的 URL 更改时,它会超时。

任何机构都可以分享一些建议吗?

【问题讨论】:

    标签: nginx nginx-reverse-proxy nginx-config


    【解决方案1】:

    这是代理的典型问题。您想要的是在代理时覆盖返回网址

    location /{
       proxy_pass https://ms-tsg.cp.cloud;
       proxy_ssl_server_name on;
       proxy_set_header Host ms-tsg.cp.cloud;
       proxy_redirect https://auth-tsg.cp.cloud https://k8s2.cluster.mstsg.com
       proxy_ssl_server_name on;
    }
    

    然后您需要再创建一台虚拟服务器,将server_name 设置为k8s2.cluster.mstsg.com,然后将proxy_pass 设置为auth-tsg.cp.cloud

    【讨论】:

    • 谢谢塔伦。我已经进行了提供的更改,现在我在ms-tsg.cp.cloud 上看到了超时。为了覆盖我在 proxy_redirect 中添加了ms-tsg.cp.cloud 的 URL,之后我无法启动 nginx。请参阅我添加的配置。我在 nginx 日志中得到的错误 ==== /etc/nginx/sites-enabled/reverse-proxy.conf:17 nginx 中的“proxy_redirect”指令中的参数数量无效:配置文件 /etc/nginx/nginx.conf 测试失败=====你能分享你的想法吗
    • 位置/{ proxy_pass ms-tsg.cp.cloud;代理重定向auth-tsg.cp.cloudk8s2.cluster.mstsg.comms-tsg.cp.cloud; proxy_set_header 主机 ms-tsg.cp.cloud; proxy_ssl_server_name 开启; }
    • proxy_redirect redirect 有两个参数。 proxy_redirect <searchtext> <replacementtext>,如果您需要多个替换,请使用多个 proxy_redirect 指令。一旦你纠正了这个错误,它应该可以工作
    • 谢谢。现在它的加载,但现在它的重定向错误太多。 “k8s.cluster.mstsg.com”重定向太多次。我们是否需要在代理传递指令上添加任何额外的配置?
    • 你需要有proxy_redirect https://auth-tsg.cp.cloud https://k8sauth.cluster.mstsg.com并在另一个服务器块中使用k8sauth.cluster.mstsg.com,因为你需要一种方法来分隔两个主机名
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-11-02
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 2016-11-17
    • 2017-02-27
    • 2017-04-24
    相关资源
    最近更新 更多