NutzCN Logo
问答 求助帖 登录成功 莫名其妙 返回302 刷新页面才能登录成功
发布于 156天前 作者 Hamming 510 次浏览 复制 上一个帖子 下一个帖子
标签:

求助帖 登录成功 莫名其妙 返回302 刷新页面才能登录成功

Request URL: https://XXX.com/index
Request Method: GET
Status Code: 302  (from disk cache)
Remote Address: 39.100.118.235:443
Referrer Policy: no-referrer-when-downgrade
Cache-Control: max-age=600
Content-Length: 0
Date: Thu, 22 Aug 2019 05:50:56 GMT
Expires: Thu, 22 Aug 2019 06:00:56 GMT
Location: http://XXX.com/login;JSESSIONID=rausoibhs0j05o89hnhd9mkj4v
Server: nginx/1.16.1
Provisional headers are shown
Referer: https://XXX.com/login;JSESSIONID=rausoibhs0j05o89hnhd9mkj4v
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36

nginx 配置

server {
    listen 80;
    server_name XXX.com;
    rewrite ^(.*) https://$server_name$1 permanent;
}

server {
    listen              443 ssl;
    server_name         www.XXX.com;
    keepalive_timeout   70;

    ssl_certificate     a.pem;
    ssl_certificate_key a.key;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;

    location / {
    	proxy_pass http://localhost:8080;
    	# 对应端口号8088 proxy_set_header X-Real-IP $remote_addr;
    	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    	proxy_set_header X-Forwarded-Proto https;
    	proxy_set_header Host $http_host;
    	expires 10m;
    	#root   /opt/nodejs/deal;
    	#index  index.html index.htm;
    }
    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
6 回复

shiro 如何能判断 已经登录 直接跳转到首页呢?

    @GET
    @At("")
    @Ok("th:/login.html")
    public void loginPage(  HttpServletRequest req) {
        req.setAttribute("base", Globals.AppBase);
    }

修改代码 如下 避免 重复登录
但是 页面 一直登录不上去问题 有些不太明白

    @GET
    @At("")
    @Ok("re")
    public String loginPage(  HttpServletRequest req) {
        req.setAttribute("base", Globals.AppBase);
        User user = ShiroUtils.getSysUser();
        if (Lang.isNotEmpty(user)) {
            return ">>:/index";
        }
        return "th:/login.html";
    }

还有 退出登录 莫名其妙跑去了

https://www.domain.com/login

貌似改成这样就可以了:

proxy_set_header Host $host;

请求地址变成

https://XXX.com/login;JSESSIONID=svda7vge96gtprevime96mle3m

网络请求 出现多次 302

Request URL: https://XXX.com/index
Request Method: GET
Status Code: 302  (from disk cache)
Remote Address: X.X.X.X:443
Referrer Policy: no-referrer-when-downgrade
Cache-Control: max-age=600
Content-Length: 0
Date: Thu, 22 Aug 2019 06:32:58 GMT
Expires: Thu, 22 Aug 2019 06:42:58 GMT
Location: http://XXX.com/login;JSESSIONID=svda7vge96gtprevime96mle3m
Server: nginx/1.16.1
Provisional headers are shown
Referer: https://XXX.com/login;JSESSIONID=svda7vge96gtprevime96mle3m
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36

Request URL: http://XXX.com/login;JSESSIONID=svda7vge96gtprevime96mle3m
Request Method: GET
Status Code: 301 Moved Permanently (from disk cache)
Remote Address: X.X.X.X:80
Referrer Policy: no-referrer-when-downgrade
Content-Length: 169
Content-Type: text/html
Date: Thu, 22 Aug 2019 06:32:58 GMT
Location: https://XXX.com/login;JSESSIONID=svda7vge96gtprevime96mle3m
Server: nginx/1.16.1
Provisional headers are shown
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36

一直登录不上 是什么原因呢

nginx 改了 还是不行

添加回复
请先登陆
回到顶部