Nginx 重写建议

问题描述

我很感激有关如何在以下场景中执行代理或重写规则的建议。 下面的公共 URL 将请求发送到端口 443 上的后端服务器 (intserver)。

公共网址 = https://wc029.domain.com

内部服务器然后在内部重定向到端口 40000 上的各种其他内部 URL - https://intserver:40000/sld/saml2/idp/sso(是一个) - 但将其发送回显然不能的浏览器命中内部主机名的公共 DNS。 我需要块/规则来允许将任何响应改回外部 URL。

我之前在 IIS 中使用过反向代理,这是由相应的出站规则处理的,但无法理解如何在 Nginx 中实现这一点。

我怀疑这很简单,需要在服务器块中添加一些东西,但考虑到这是一个带有多个其他服务器块的生产服务器,我宁愿在使用配置付款之前在这里寻求建议,但我不能似乎在其他场景中找到了我理解的东西。

谁能告诉我我方法错误! ;)

server {
  listen 443 ssl;
  listen [::]:443 ssl;

  add_header Strict-Transport-Security "max-age=63072000; includeSubdomains;";
  add_header x-frame-options SAMEORIGIN;
  add_header X-Content-Type-Options nosniff;
  add_header X-XSS-Protection "1; mode=block";
  #add_header Content-Security-Policy "default-src 'self'; script-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; font-src 'self' data:; frame-src 'self'; connect-src 'self' https://apis.google.com; object-src 'none'";

# The below allow and deny rules can be set to allow access.The Deny rule MUST be uncommented and then add multiple allow lines for the IP range required.
  #allow;
  #deny  all;

  server_name wc029.domain.com;
  ssl_certificate /etc/pki/cert.crt;
  ssl_certificate_key /etc/pki/priv.key;
  ssl_protocols       TLSv1.2 TLSv1.3;
  ssl_ciphers         ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;

  access_log /var/log/Nginx/reverse-access.log;
  error_log /var/log/Nginx/reverse-error.log;

  location /
  {
      limit_except GET POST {deny all;}
      proxy_set_header X-Real-IP  $remote_addr;
      proxy_set_header X-Forwarded-For $remote_addr;
      proxy_set_header Host $host;
      proxy_pass https://intserver/;
      proxy_set_header X-Forwarded-Proto https;
  }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)