go-proxy-bingai icon indicating copy to clipboard operation
go-proxy-bingai copied to clipboard

带端口号就没法用

Open Chun-J1 opened this issue 1 year ago • 11 comments

因为不想备案太麻烦了,所以使用了自己服务器开公网,自己申请的公网ip是没有80和443端口的,随便选用了一个作为nginx转发端口。网站是能访问的,就是生成对话的API默认使用的就是无端口的也就是默认走443去了,这一点能改一下吗?改为根据网页访问地址拼接API。 图片

图片

Chun-J1 avatar Jun 13 '23 06:06 Chun-J1

可以通过修改Bing AI的配置文件来修改生成对话的API地址。具体来说,您需要修改config.js文件中的baseUrl参数,将其设置为您的API地址,例如: baseUrl: 'https://yourdomain.com:yourport/api' 其中,yourdomain.com是您的域名,yourport是您的API端口号。这样,Bing AI将会使用您指定的API地址来生成对话。 请注意,如果您的API地址没有正确配置SSL证书,Bing AI可能无法正常连接到API。因此,建议您在使用SSL证书保护API的同时,将SSL证书的配置信息也添加到Bing AI的配置文件中。

获取Outlook for Androidhttps://aka.ms/AAb9ysg


From: 简单男孩 @.> Sent: Tuesday, June 13, 2023 2:34:02 PM To: adams549659584/go-proxy-bingai @.> Cc: Subscribed @.***> Subject: [adams549659584/go-proxy-bingai] 带端口号就没法用 (Issue #223)

因为不想备案太麻烦了,所以使用了自己服务器开公网,自己申请的公网ip是没有80和443端口的,随便选用了一个作为nginx转发端口。网站是能访问的,就是生成对话的API默认使用的就是无端口的也就是默认走443去了,这一点能改一下吗?改为根据网页访问地址拼接API。 [图片]https://user-images.githubusercontent.com/54700619/245372349-cfc3949b-45f4-45f1-b409-e62cb3a140ac.png

[图片]https://user-images.githubusercontent.com/54700619/245372242-f4887b58-fbe6-4da1-be09-bae07dff155c.png

― Reply to this email directly, view it on GitHubhttps://github.com/adams549659584/go-proxy-bingai/issues/223, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A6QGHOKVFNVPHJ6BPCDYLULXLACVVANCNFSM6AAAAAAZELRNNQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>

fanrengyiping avatar Jun 13 '23 08:06 fanrengyiping

用docker部署的,怎么修改呢

socosfly avatar Jun 14 '23 13:06 socosfly

我也遇到端口号问题了,最新版1.87存在两个问题:1.rb里脚本的fetch没端口号;2.cdx/bg-sprite.png背景图没端口号; 端口号问题解决: 1.fetch请求可以通过重写fetch方法解决,背景图不知道可不可以根据监听样式修改; window.fetch = function (url, initData) { const that = this; if (url && url.indexOf(location.host) === -1 && url.indexOf(location.hostname) !== -1) { url = url.replace(location.hostname, location.host); }; return _oldFetch.apply(that, [url, initData]); }; 2.nginx不要使用proxy_set_header Host $host,默认$host变量好像是不带端口号的;给host配置成具体域名,或者变量拼接上端口; add_header X-Served-By $host; proxy_set_header Host "xxx:8443"; proxy_set_header X-Forwarded-Scheme $scheme; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://localhost:8442/; 3.改go代码,作者是通过originalHost = req.Host然后用originalHost替换掉微软地址的,可以修改proxy.go逻辑

liuzhiguo11 avatar Jun 15 '23 13:06 liuzhiguo11

config.js

只找到这一个config.js,是这个baseUrl吗? 图片

Chun-J1 avatar Jun 16 '23 01:06 Chun-J1

我也遇到端口号问题了,最新版1.87存在两个问题:1.rb里脚本的fetch没端口号;2.cdx/bg-sprite.png背景图没端口号; 端口号问题解决: 1.fetch请求可以通过重写fetch方法解决,背景图不知道可不可以根据监听样式修改; window.fetch = function (url, initData) { const that = this; if (url && url.indexOf(location.host) === -1 && url.indexOf(location.hostname) !== -1) { url = url.replace(location.hostname, location.host); }; return _oldFetch.apply(that, [url, initData]); }; 2.nginx不要使用proxy_set_header Host $host,默认$host变量好像是不带端口号的;给host配置成具体域名,或者变量拼接上端口; add_header X-Served-By $host; proxy_set_header Host "xxx:8443"; proxy_set_header X-Forwarded-Scheme $scheme; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://localhost:8442/; 3.改go代码,作者是通过originalHost = req.Host然后用originalHost替换掉微软地址的,可以修改proxy.go逻辑

方法2试过了不行,会导致网页都打不开。我试试方法3

Chun-J1 avatar Jun 16 '23 01:06 Chun-J1

作者能不能修复一下,就是判断一下有无端口号,有的话拼接上去

Chun-J1 avatar Jun 16 '23 02:06 Chun-J1

我也遇到端口号问题了,最新版1.87存在两个问题:1.rb里脚本的fetch没端口号;2.cdx/bg-sprite.png背景图没端口号; 端口号问题解决: 1.fetch请求可以通过重写fetch方法解决,背景图不知道可不可以根据监听样式修改; window.fetch = function (url, initData) { const that = this; if (url && url.indexOf(location.host) === -1 && url.indexOf(location.hostname) !== -1) { url = url.replace(location.hostname, location.host); }; return _oldFetch.apply(that, [url, initData]); }; 2.nginx不要使用proxy_set_header Host $host,默认$host变量好像是不带端口号的;给host配置成具体域名,或者变量拼接上端口; add_header X-Served-By $host; proxy_set_header Host "xxx:8443"; proxy_set_header X-Forwarded-Scheme $scheme; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://localhost:8442/; 3.改go代码,作者是通过originalHost = req.Host然后用originalHost替换掉微软地址的,可以修改proxy.go逻辑

方法三:可以解决背景图的问题

        if strings.HasSuffix(location, "cdx/bg-sprite.png") {
		res.Header.Set("Location", DOMAIN_URL.String()+location[len(delLocationDomain):])
	} else {
		res.Header.Set("Location", location[len(delLocationDomain):])
	}

hanxm avatar Jun 20 '23 04:06 hanxm

我的完整nginx配置,配置里有引入外边文件,是从nginx-proxy-manager里拷的 ;1.87版是正常的,登录后聊天记录问题要更新js文件。 因为443已经被frp占了,又不想frps再走一层代理才这样用的,着实废了番脑筋。

user  root;
worker_processes  1;

#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 {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    map $http_upgrade $connection_upgrade {
            default upgrade;
            ''      close;
    }
    server {
        listen       8443   ssl;
        server_name  域名;
        ssl on;
        include conf.d/include/ssl-ciphers.conf;
	ssl_certificate /etc/nginx/certificate/fullchain1.pem;
  	ssl_certificate_key /etc/nginx/certificate/privkey1.pem;
        proxy_http_version                 1.1;
        proxy_set_header Upgrade           $http_upgrade;
        proxy_set_header Connection        $connection_upgrade;
        location /sydney/ChatHub {
            proxy_pass http://127.0.0.1:8442;
            proxy_http_version                 1.1;
            proxy_set_header Upgrade           $http_upgrade;
            proxy_set_header Connection        $connection_upgrade;
            proxy_set_header Host              "$host:$server_port";
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host  "$host:$server_port";
            proxy_set_header X-Forwarded-Port  $server_port;
        }

        location / {
            proxy_pass http://127.0.0.1:8442;
            proxy_set_header Host              "$host:$server_port";    
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host  "$host:$server_port";
            proxy_set_header X-Forwarded-Port  $server_port;
        } 
    }
}

启动应用

PORT=8442 nohup ./go-proxy-bingai &

liuzhiguo11 avatar Jun 20 '23 05:06 liuzhiguo11

我的完整nginx配置,配置里有引入外边文件,是从nginx-proxy-manager里拷的 ;1.87版是正常的,登录后聊天记录问题要更新js文件。 因为443已经被frp占了,又不想frps再走一层代理才这样用的,着实废了番脑筋。

user  root;
worker_processes  1;

#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 {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    map $http_upgrade $connection_upgrade {
            default upgrade;
            ''      close;
    }
    server {
        listen       8443   ssl;
        server_name  域名;
        ssl on;
        include conf.d/include/ssl-ciphers.conf;
	ssl_certificate /etc/nginx/certificate/fullchain1.pem;
  	ssl_certificate_key /etc/nginx/certificate/privkey1.pem;
        proxy_http_version                 1.1;
        proxy_set_header Upgrade           $http_upgrade;
        proxy_set_header Connection        $connection_upgrade;
        location /sydney/ChatHub {
            proxy_pass http://127.0.0.1:8442;
            proxy_http_version                 1.1;
            proxy_set_header Upgrade           $http_upgrade;
            proxy_set_header Connection        $connection_upgrade;
            proxy_set_header Host              "$host:$server_port";
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host  "$host:$server_port";
            proxy_set_header X-Forwarded-Port  $server_port;
        }

        location / {
            proxy_pass http://127.0.0.1:8442;
            proxy_set_header Host              "$host:$server_port";    
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host  "$host:$server_port";
            proxy_set_header X-Forwarded-Port  $server_port;
        } 
    }
}

启动应用

PORT=8442 nohup ./go-proxy-bingai &

大佬 按你的配置之后出现了这种情况 图片

 server {
    server_name xxxxx;
    listen 23004 ssl http2;
    ssl_certificate /root/download/httpsZS/certificate.crt;
    ssl_certificate_key /root/download/httpsZS/private.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
    proxy_http_version                 1.1;
    proxy_set_header Upgrade           $http_upgrade;
    proxy_set_header Connection        $connection_upgrade;

    location / {
      proxy_pass http://127.0.0.1:23003;
      proxy_set_header Host              "$host:$server_port";    
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host  "$host:$server_port";
            proxy_set_header X-Forwarded-Port  $server_port;
    }

    location /sydney/ChatHub {
      proxy_pass http://127.0.0.1:23003;
      proxy_http_version                 1.1;
            proxy_set_header Upgrade           $http_upgrade;
            proxy_set_header Connection        $connection_upgrade;
            proxy_set_header Host              "$host:$server_port";
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host  "$host:$server_port";
            proxy_set_header X-Forwarded-Port  $server_port;
    }

}

Chun-J1 avatar Jun 20 '23 05:06 Chun-J1

没办法...go的东西不太会搞,也不会编译

Chun-J1 avatar Jun 20 '23 05:06 Chun-J1

我也是看其他isuues配置的,这段websockert的配置有没有配置

map $http_upgrade $connection_upgrade {
            default upgrade;
            ''      close;
}

ERR_TOO_MANY_REDIRECTS 是重定向次数过多吧。内地服务器还是香港或海外的的,我的是香港的。内地服务器要配置代理,可能代理配置有问题。

liuzhiguo11 avatar Jun 20 '23 06:06 liuzhiguo11