首页 > 系统相关 >配置nginx支持

配置nginx支持

时间:2024-05-16 21:53:00浏览次数:18  
标签:http lua 配置 支持 access nginx proxy openresty

langchain-chatchat使用了streamlit,打算前置一个ng做鉴权,该框架使用了websocket,也用/作为url,ng(openresty)的配置如下:

# nginx.conf  --  docker-openresty
#
# This file is installed to:
#   `/usr/local/openresty/nginx/conf/nginx.conf`
# and is the file loaded by nginx at startup,
# unless the user specifies otherwise.
#
# It tracks the upstream OpenResty's `nginx.conf`, but removes the `server`
# section and adds this directive:
#     `include /etc/nginx/conf.d/*.conf;`
#
# The `docker-openresty` file `nginx.vh.default.conf` is copied to
# `/etc/nginx/conf.d/default.conf`.  It contains the `server section
# of the upstream `nginx.conf`.
#
# See https://github.com/openresty/docker-openresty/blob/master/README.md#nginx-config-files
#

#user  nobody;
#worker_processes 1;

# Enables the use of JIT for regular expressions to speed-up their processing.
pcre_jit on;



#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    server_tokens off;
    include       mime.types;
    default_type  application/octet-stream;
    # 放开上传文件大小,用于上传知识文档
    client_max_body_size 300M;

    # Enables or disables the use of underscores in client request header fields.
    # When the use of underscores is disabled, request header fields whose names contain underscores are marked as invalid and become subject to the ignore_invalid_headers directive.
    # underscores_in_headers off;

    #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  logs/access.log  main;

        # Log in JSON Format
        # log_format nginxlog_json escape=json '{ "timestamp": "$time_iso8601", '
        # '"remote_addr": "$remote_addr", '
        #  '"body_bytes_sent": $body_bytes_sent, '
        #  '"request_time": $request_time, '
        #  '"response_status": $status, '
        #  '"request": "$request", '
        #  '"request_method": "$request_method", '
        #  '"host": "$host",'
        #  '"upstream_addr": "$upstream_addr",'
        #  '"http_x_forwarded_for": "$http_x_forwarded_for",'
        #  '"http_referrer": "$http_referer", '
        #  '"http_user_agent": "$http_user_agent", '
        #  '"http_version": "$server_protocol", '
        #  '"nginx_access": true }';
        # access_log /dev/stdout nginxlog_json;

    # See Move default writable paths to a dedicated directory (#119)
    # https://github.com/openresty/docker-openresty/issues/119
    client_body_temp_path /var/run/openresty/nginx-client-body;
    proxy_temp_path       /var/run/openresty/nginx-proxy;
    fastcgi_temp_path     /var/run/openresty/nginx-fastcgi;
    uwsgi_temp_path       /var/run/openresty/nginx-uwsgi;
    scgi_temp_path        /var/run/openresty/nginx-scgi;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

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

    # Don't reveal OpenResty version to clients.
    # server_tokens off;

    lua_package_path "/usr/local/openresty/lualib/?.lua;;";
    lua_package_cpath "/usr/local/openresty/lualib/?.so;;";

    # 定义websocket支持
    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }

    server {
        listen 80;

        location / {
            # 使用access.lua进行鉴权
            access_by_lua_file /usr/local/openresty/lualib/access.lua; 
            proxy_pass http://127.0.0.1:7204/;
        }

        location ^~ /static {
            # access_by_lua_file /usr/local/openresty/lualib/access.lua;
            proxy_pass http://127.0.0.1:7204/static;
        }

        location ^~ /health {
            #access_by_lua_file /usr/local/openresty/lualib/access.lua;
            proxy_pass http://127.0.0.1:7204/health;
        }

        location ^~ /host-config {
            #access_by_lua_file /usr/local/openresty/lualib/access.lua;
            proxy_pass http://127.0.0.1:7204/host-config;
        }

        location ^~ /vendor {
            #access_by_lua_file /usr/local/openresty/lualib/access.lua;
            proxy_pass http://127.0.0.1:7204/vendor;
        }

        # 大模型流式输出使用websocket,通过此路径刷新信息
        location /_stcore/stream {
            #access_by_lua_file /usr/local/openresty/lualib/access.lua;
            proxy_pass http://127.0.0.1:7204/_stcore/stream;
            proxy_http_version 1.1;
            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr; # 客户端真实IP
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 包含所有代理服务器的IP,客户端IP在最前面
            proxy_set_header Host $host;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_read_timeout 86400;
        }
    }
}

 

标签:http,lua,配置,支持,access,nginx,proxy,openresty
From: https://www.cnblogs.com/badwood316/p/18196819

相关文章

  • openGauss JDBC配置
    JDBC配置目前,openGauss相关的第三方工具都是通过JDBC进行连接的,此部分将介绍工具配置时的注意事项。连接参数【关注】第三方工具通过JDBC连接openGauss时,JDBC向openGauss发起连接请求,会默认添加以下配置参数,详见JDBC代码ConnectionFactoryImpl类的实现。params={{"user"......
  • openGauss Linux下配置数据源
    Linux下配置数据源将openGauss提供的ODBCDRIVER(psqlodbcw.so)配置到数据源中便可使用。配置数据源需要配置“odbc.ini”和“odbcinst.ini”两个文件(在编译安装unixODBC过程中生成且默认放在“/usr/local/etc”目录下),并在服务器端进行配置。操作步骤获取unixODBC源码包。获取......
  • Maven安装与配置,Idea配置Maven
    maven安装之前要先安装jdk,请确保你的系统已经安装了jdk环境。一、下载Maven选择你需要的maven版本下载:官网下载传送门我使用的是3.6.1版本:maven-3.6.1-bin.zip二、安装把下载好的maven压缩包解压到一个没有中文,空格或其他特殊字符的文件夹,如:三、配置环境变量1.右键此电脑......
  • ArchLinux-环境配置操作手册-全-
    ArchLinux环境配置操作手册(全)原文:zh.annas-archive.org/md5/537398CD561E23B9C0417DF43FA5C99F译者:飞龙协议:CCBY-NC-SA4.0前言ArchLinux是一种独立开发的通用GNU/Linux发行版,针对i686/x86-64系统进行了优化。该发行版足够灵活,适合任何角色/需求。它的设计侧重于简......
  • windows server2012下配置hyper-v的网络步骤
    今天分享一个绝对可用的hyper-v虚拟机的网络配置方法,亲测可用第一步:在hyper-v上配置网络,设置虚拟交换机仅内部第二步:在主网卡上设置共享网络第三步在虚拟网卡上配置,选择ipv4配置ip地址设置: 192.168.10.1然后安装虚拟机系统,在系统里面设置为:这样就可用连上了。 ......
  • 本机使用 Nginx 代理域名
    为了使用Nginx代理一个域名,您需要在Nginx配置文件中设置一个服务器块(serverblock),并指定该域名以及代理的配置。以下是一个基本的配置示例:http{server{listen80;#监听的端口server_nameexample.com;#要代理的域名location/{......
  • 本机使用 Nginx 代理域名
    为了使用Nginx代理一个域名,您需要在Nginx配置文件中设置一个服务器块(serverblock),并指定该域名以及代理的配置。以下是一个基本的配置示例:http{server{listen80;#监听的端口server_nameexample.com;#要代理的域名location/{......
  • nginx: /lib64/libcrypt.so.1: version `XCRYPT_2.0' not found
    1.报错信息[root@ba6649b3a783sbin]#./nginx--t./nginx:/lib64/libcrypt.so.1:version`XCRYPT_2.0'notfound(requiredby./nginx)./nginx:/lib64/libc.so.6:version`GLIBC_2.27'notfound(requiredby./nginx)./nginx:/lib64/libc.so.6:version......
  • IDEA配置Maven
    原文链接:https://blog.csdn.net/leah126/article/details/132020904一、Maven下载首先我们进入maven官方网站,进入网页后,点击Download去下载。下载免安装版,解压即可,解压至磁盘任意目录,尽量不要取中文名如下图:二、配置Maven环境变量 打开cmd命令行,输入mvn-v,显示出maven的版......
  • 10分钟搞定Mysql主从部署配置
    流程Master数据库安装Slave数据库安装配置Master数据库配置Slave数据库网络信息Master数据库IP:192.168.198.133Slave数据库IP:192.168.198.132配置Master数据库在Master数据库安装完毕后,修改/etc/my.cnf[mysqld]server-id=1\\指定ID,主从的两台虚拟机ID必须不同log......