Nginx uniq session 并清除cookie

Nginx uniq session 并清除cookie

我正在使用 nginx 来重定向我的 API 代码和 apache guacamole。我遇到一个问题,我需要使用多用户连接,但如果我登录到 Auser 并尝试连接到 Buser(同一浏览器),它会尝试重新连接到 Auser,即使 URL 完全不同:

Auser:

https://myapp/#/client/MjIyAGMAcG9zdGdyZXNxbA==/?username=Auser&password=vDeMsKqCG5F

布瑟:

https://myapp/#/client/NTQxAGMAcG9zdGdyZXNxbA==/?username=Buser&password=0aiOMa4o08pb

nginx 配置:

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    fastcgi_read_timeout 600;
    proxy_read_timeout 600;
    keepalive_timeout  600;


    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        off;
    #tcp_nopush     on;


    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

nginx/mysite.template:

server {
        listen       80;
        server_name  localhost;
        server_name reverse.proxy
        server_tokens off;

        location / {
        proxy_pass http://guacamole:8080/guacamole/;
        proxy_buffering off;
        proxy_hide_header       Set-Cookie;
        proxy_ignore_headers    Set-Cookie;
        proxy_set_header        Cookie "";
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $http_connection;
        proxy_cookie_path /guacamole/ /;
        access_log on;
        client_max_body_size 4096m;
        }

        location /api {
        proxy_pass              http://api:5001/;
        rewrite /api/(.*) /$1  break;
        proxy_hide_header       Set-Cookie;
        proxy_ignore_headers    Set-Cookie;
        proxy_set_header        Cookie "";
        proxy_buffering off;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $http_connection;
        access_log on;
        client_max_body_size 4096m;
        }
}

尝试通过以下方式删除 cookie:

    proxy_hide_header       Set-Cookie;
    proxy_ignore_headers    Set-Cookie;
    proxy_set_header        Cookie "";

但结果相同。我怎样才能让 ngnix 为每个请求提供唯一的会话?忽略已经连接的用户。也许是 chrome 浏览器共享会话数据的问题,但 nginx 设置能在这里提供帮助吗?

相关内容