为vicuna增加用户认证

410阅读 0评论2023-06-25 zenith518
分类:大数据


简单而快速的方案是在vicuna前端增加一个nginx web 服务器,利用nginx reverse proxy的机制。
并启用简单的用户认证机制,就可以实现了,非常快速便捷高效。对于简单的demo非常实用。

相关的nginx配置如下:

点击(此处)折叠或打开

  1. upstream backend {
  2.         server 127.0.0.1:7860; # Replace with the actual WebSocket server address
  3. }

  4. server {
  5.         listen 80 default_server;
  6.         listen [::]:80 default_server;

  7.         # SSL configuration
  8.         #
  9.         # listen 443 ssl default_server;
  10.         # listen [::]:443 ssl default_server;
  11.         #
  12.         # Note: You should disable gzip for SSL traffic.
  13.         # See: https://bugs.debian.org/773332
  14.         #
  15.         # Read up on ssl_ciphers to ensure a secure configuration.
  16.         # See: https://bugs.debian.org/765782
  17.         #
  18.         # Self signed certs generated by the ssl-cert package
  19.         #

    点击(此处)折叠或打开

    1. server_name _;

    2.         location / {
    3.                 auth_basic "Restricted Access";
    4.                 auth_basic_user_file /etc/nginx/.htpasswd;
    5.                 proxy_pass http://localhost:7860;
    6.                 # First attempt to serve request as file, then
    7.                 # as directory, then fall back to displaying a 404.
    8.                 proxy_set_header Host $host;
    9.                 proxy_set_header X-Real-IP $remote_addr;
    10.                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    11.                 proxy_set_header X-Forwarded-Proto $scheme;
    12.                 try_files $uri $uri/ =404;
    13.         }

    点击(此处)折叠或打开

    1. location /theme.css {
    2.                 proxy_pass http://localhost:7860/theme.css;
    3.                 # First attempt to serve request as file, then
    4.                 # as directory, then fall back to displaying a 404.
    5.                 proxy_set_header Host $host;
    6.                 proxy_set_header X-Real-IP $remote_addr;
    7.                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    8.                 proxy_set_header X-Forwarded-Proto $scheme;
    9.         }

    点击(此处)折叠或打开

    1. location /assets/ {
    2.                 proxy_pass http://localhost:7860/assets/;
    3.                 # First attempt to serve request as file, then
    4.                 # as directory, then fall back to displaying a 404.
    5.                 proxy_set_header Host $host;
    6.                 proxy_set_header X-Real-IP $remote_addr;
    7.                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    8.                 proxy_set_header X-Forwarded-Proto $scheme;
    9.         }


    点击(此处)折叠或打开

    1. location /queue/join {
    2.                 proxy_pass http://backend/queue/join;
    3.                 proxy_http_version 1.1;
    4.                 proxy_set_header Upgrade $http_upgrade;
    5.                 proxy_set_header Connection "Upgrade";
    6.                 proxy_redirect off;
    7.         }




用hppasswd 指令生成用户名和密码, 存到 /etc/nginx/.htpasswd 文件中。

zentih
2023-06-25
上一篇:python 虚拟环境快速切换
下一篇:精妙代码计时器