微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Nginx 重写建议

如何解决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 举报,一经查实,本站将立刻删除。