Nginx HTTPS重定向异常

Nginx HTTPS重定向异常,nginx,Nginx,我正在开发一个新项目,该项目使用强制HTTPS导航,其中我们需要显示包含非HTTPS内容的iframe 问题在于,在Nginx中,我强制使用HTTPS,并对任何请求进行重定向 我想在URL demo.html的重写中添加一个“例外”,我不知道如何正确地执行此操作,非常感谢任何帮助。谢谢 这是我们的Nginx配置文件: server { listen 80; listen [::]:80; server_name www.domain

我正在开发一个新项目,该项目使用强制HTTPS导航,其中我们需要显示包含非HTTPS内容的iframe

问题在于,在Nginx中,我强制使用HTTPS,并对任何请求进行重定向

我想在URL demo.html的重写中添加一个“例外”,我不知道如何正确地执行此操作,非常感谢任何帮助。谢谢

这是我们的Nginx配置文件:

server {
    listen       80;
    listen       [::]:80;
    server_name
        www.domain.com
        domain.com
      ;
    rewrite        ^ https://$server_name$request_uri? permanent;
}

server {
    listen       443 ssl spdy;
    listen       [::]:443 ssl spdy;
    server_name
        www.domain.com
        domain.com
      ;

    ### redirect www to no www with client code 301 ###
    if ($host = 'www.domain.com') {
        rewrite  ^/(.*)$  https://domain.com/$1  permanent;
    }

    root   /srv/users/public;

    proxy_set_header    Host              $host;
    proxy_set_header    X-Real-IP         $remote_addr;
    proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-SSL   on;
    proxy_set_header    X-Forwarded-Proto $scheme;
}
index index.php;

# Don't serve hidden files.
location ~ /\. {
    deny all;
}

location /
{
    try_files $uri /index.php?$args;
}

location ~ \.php$ {
  include       fastcgi_params;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

  fastcgi_param KOHANA_ENV PRODUCTION;

  fastcgi_pass  127.0.0.1:2222;

  try_files     $uri =404;
} 

最后,我将为所有人禁用HTTPS重定向,并允许在没有HTTPS的情况下浏览


所以我所做的就是强制主页使用HTTPS,我打印的其余链接都是HTTPS,除了我需要的那个不使用HTTPS的链接。我这样做了:##我们只强制将HTTPS发送到主页,但如果他们愿意,我们允许不使用HTTPS进行浏览

## we only force the HTTPS to the home page but we allow to browse without HTTPS if they want to.
if ($request_uri = /) { 
  set $test  A; 
} 
if ($scheme = 'http') { 
  set $test  "${test}B"; 
} 
if ($test = AB) { 
    rewrite  ^/(.*)$  https://yclas.com/$1  permanent;
} 
## END if Hack

您的demo.html url看起来怎么样?您好,将是或万一是更简单的domain.com/domain/demo/6(6==数字),非常感谢!最后,我将禁用HTTPS重定向,并允许不使用HTTPS的浏览。因此,我所做的是强制主页为HTTPS,我打印的其余链接始终为HTTPS,除了我需要的不使用HTTPS的链接。我这样做了:##我们只强制将HTTPS发送到主页,但如果他们愿意,我们允许不使用HTTPS进行浏览。if($request_uri=/){set$test A;}if($scheme='http'){set$test“${test}B”;}if($test=AB){rewrite^/(.*)$permanent;}##END if Hack