Ice9Coffee / HoshinoBot

A qqbot for Princess Connect Re:Dive (and other usage :)
GNU General Public License v3.0
1.41k stars 413 forks source link

希望提供对网页端redirect(转发)的支持 #138

Closed Cryspia closed 4 years ago

Cryspia commented 4 years ago

通过浏览配置文件和搜索源代码,我没有找到可以更改public address以及 public path的设置(如果有,请close这个issue)。 如此一来,public ip和端口必须等于bot.py中的HOST以及PORT,用户无法使用转发的方式将服务器隐藏在一个web server(如 apacheeximnginx )之后。 提供转发的支持可以提高服务器的安全性,也能够更好地支持网页服务器多用的情况以及https,希望能予以考虑。

Ice9Coffee commented 4 years ago

HOST设为127.0.0.1,PORT任意,nginx对外开放80和443,根据url转发至PORT。应当可以实现你所需要的功能。(Hoshino本体并无网页端,如果你使用了带网页的插件,请咨询插件作者)

noahzark commented 4 years ago

附一个个人载用的nginx配置 希望有帮助 :)

upstream waifu {
        # your port
        server 127.0.0.1:8080;
}

server {
        listen          80;
        server_name     xxx.xxx.com;

        access_log /var/log/nginx/access-waifu.log;
        error_log /var/log/nginx/error-waifu.log;

        location /ws {
                proxy_redirect off;
                proxy_pass http://waifu;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header Host $http_host;

                # prevents disconnect
                proxy_read_timeout 2m;

                # Show realip
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        location / {
                # yobot stuff
                proxy_pass http://waifu;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

}