nginx代理tomcat服务器,访问Nginx用Https,代理用http,但是tomcat重定向的页面无法访问

nginx.conf


        location / {
                #  echo "123";
                proxy_next_upstream error timeout http_503;
                proxy_pass http://thjg-mgr;
                # proxy_redirect off;
                proxy_redirect ~^http://([^:]+)(:\d+)?(.*)$  https://$1$3;
                proxy_store off;

                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header REMOTE-HOST $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                # proxy_set_header X-Forwarded-Proto https;

                client_max_body_size 8m;
                proxy_ignore_client_abort on;
                client_body_buffer_size 128k;
                proxy_connect_timeout 200;
                proxy_send_timeout 200;
                proxy_read_timeout 200;
                proxy_buffer_size 8k;
                proxy_buffers 8 8k;
                proxy_busy_buffers_size 8k;
                proxy_temp_file_write_size 8k;
                }

        }

 

做了https 但是遇到重定向时,会把https 变成http 导致出现:

Mixed Content: The page at 'https://...../#' was loaded over HTTPS, but requested an insecure form action 'http://.../**/**'. This request has been blocked; the content must be served over HTTPS.

增加:

proxy_redirect ~^http://([^:]+)(:\d+)?(.*)$  https://$1$3;

你可能感兴趣的:(nginx代理tomcat服务器,访问Nginx用Https,代理用http,但是tomcat重定向的页面无法访问)