Problems with Nginx reverse proxy

problem: use Spring Boot development, and then use Nginx reverse proxy port 8080 on the server, and then the problem arises. When you log in at the backend of the website, the user name and password are correct, which also indicates that the login is successful, but when you redirect, you return to the login page, where an interceptor is added, and the link to the backend directly goes back to the login page, which feels as if session was not created after a successful login. If you add the 8080 port, then there will not be such a problem, we have experience to help take a look, thank you.

related code:

request for login page:

server
{
    listen 80;
    server_name ;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/halo;
    
    -sharpSSL-START SSL404
    -sharperror_page 404/404.html;
    -sharpSSL-END
    
    -sharpERROR-PAGE-START  
    error_page 404 /404.html;
    error_page 502 /502.html;
    -sharpERROR-PAGE-END
    
    -sharpPHP-INFO-START  PHP

    -sharpPROXY-START
    location ~ /purge(/.*) { 
        proxy_cache_purge cache_one $host$request_uri$is_args$args;
        -sharpaccess_log  /www/wwwlogs/slogc.cc_purge_cache.log;
    }
    location / 
    {
        proxy_pass http://ip:8090;
        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 REMOTE-HOST $remote_addr;
        
        -sharp
        -sharpproxy_cache cache_one;
        -sharpproxy_cache_key $host$request_uri$is_args$args;
        -sharpproxy_cache_valid 200 304 301 302 1h;
        
        -sharp
        -sharpproxy_connect_timeout 30s;
        -sharpproxy_read_timeout 86400s;
        -sharpproxy_send_timeout 30s;
        -sharpproxy_http_version 1.1;
        -sharpproxy_set_header Upgrade $http_upgrade;
        -sharpproxy_set_header Connection "upgrade";
        
        -sharpadd_header X-Cache $upstream_cache_status;
        
        expires 12h;
    }
    
    location ~ .*\.(php|jsp|cgi|asp|aspx|flv|swf|xml)?$
    {
        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 REMOTE-HOST $remote_addr;
        proxy_pass http://123.207.101.207:8090;
        
    }
}
Mar.04,2021

because you use redirect, it can be related to this

add proxy_redirect to the nginx configuration try:

location /{
...
      proxy_redirect   / /;
...
}
Menu