After Nginx proxy HTTPS, Spring MVC web App redirect https into http

Source: Internet
Author: User
A few days ago with the Nginx proxy HTTPS, the application of redirect HTTPS to HTTP, resulting in the Web site can not access the problem, find a half-day on the internet, finally found a solution.

Although I resolved, I believe there are other friends have encountered this problem, so reprint share:

Cause Analysis:

Browser to Nginx is Https,nginx to the application server into HTTP,

Application server, and then do 302 Redirect, the return of the redirect address is good to become the address of HTTP;

The reason is the secheme value of the servlet of spring MVC,request.getscheme ()

is a scheme value in the request, all this value is set to HTTPS when the Nginx proxy

Where: Request.getscheme () return HTTP but not HTTPS.

Workaround:

Change it.

server {    listen default_server;    Location/{        Proxy_pass http://127.0.0.1:8080;        Proxy_redirect/HTTP $scheme://;    }}

The above describes the Nginx proxy HTTPS, Spring MVC Web application redirect https into HTTP, including the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.