Skip to content

云服务器远程部署指南

binary-husky edited this page Mar 31, 2024 · 7 revisions

远程服务器部署

宝塔安装教程

使用宝塔Docker-compose,5分钟内在海外服务器上搭建gpt_academic

https://github.com/binary-husky/chatgpt_academic/issues/867 (新)

https://github.com/binary-husky/chatgpt_academic/issues/442

海外云服务器(基于阿里云)Linux和公网解决方案

https://github.com/binary-husky/chatgpt_academic/issues/386

腾讯云服务器部署方案,可公网访问

https://github.com/binary-husky/chatgpt_academic/issues/163

解决腾讯云安装最新的 python 包报错问题

https://github.com/binary-husky/chatgpt_academic/issues/565

windows云服务器部署

https://github.com/binary-husky/chatgpt_academic/issues/374

nginx反向代理

https://github.com/binary-husky/chatgpt_academic/issues/155

https://github.com/binary-husky/chatgpt_academic/issues/23

Apache反向代理

https://github.com/binary-husky/gpt_academic/issues/1661

如果您需要将本项目部署到公网服务器,请设置好PORT(固定端口)和AUTHENTICATION(避免您的APIKEY被滥用),并将main.py的最后一句话修改为:

demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", share=False, server_port=PORT, auth=AUTHENTICATION) # 取消share

如果您打算使用域名,强烈建议用nginx配置反向代理。需要往配置文件增加的内容如下:

http {
    # 其他配置
    #......
    # 配置websocket
    map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
    }
upstream my_chataca {
	# 这里配置负载均衡策略
    ip_hash; # 如果使用负载均衡,建议使用ip_hash
    # 假设本项目运行的端口为8080
	server 127.0.0.1:8080 max_fails=3 fail_timeout=10;
}
server {
	listen 80;
	listen [::]:80;
	server_name yourdomain.com;
	return 301 https://yourdomain.com$request_uri;# 强制使用https
}
server {
	listen 443 ssl http2;
	listen [::]:443 ssl http2;
	server_name yourdomain.com;
	ssl_protocols TLSv1.2 TLSv1.3;
	ssl_prefer_server_ciphers on;
	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	ssl_session_tickets off;
	ssl_session_timeout 1d;
	ssl_session_cache shared:SSL:10m;
	add_header Strict-Transport-Security
		"max-age=31536000; includeSubDomains"
		always;
	ssl_certificate xxxxxx.pem; # 证书文件
	ssl_certificate_key xxxxxx.key; # 证书文件
	location / {
		proxy_pass http://my_chataca;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto https;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection $connection_upgrade;
	}
}
}